SharePoint Work flows are pretty strait forward for the most part but there are a couple items that are worth remembering. Some of them I have had to learn twice so this list I’ve made to review before I do WF implementations, in an effort to not have to learn things a third time :)
These notes are specific to Work Flows in SharePoint Designer.
1. Always save then publish.
2. If you have a test page open after the WF has been updated reload the page before initiating the WF. SharePoint will force you to do this anyway but you can lose any changes you made to test the WF.
3. When sending an e-mail via WF using a look-up person value select e-mail address, semicolon delimited for the look-up value.
4. In general, if you are using a look-up values in the WF verify it is not empty (Null) before using. If the error, Coercion Failed: Input cannot be null for this coercion, it is because a field has a null value or is empty. The Fix is to use the conditional IF-Else construct to check for Null before executing the actions, example: IF field is not empty.
5. A record seems to only be updateable by a WF once.
6. Conditional statements like IF-Else don’t move up and down so well in the WF step.
7. To create a state machine using a WF
a. Create a list or column to contain a copy of the field(s)
b. Seed the field with a copy of the content
c. Create a WF that accounts for the following conditions
d. Initial creation of the list item
i. Might be necessary to seed the list or column
e. On value change account for the following conditions
i. Different Content -> Previous Content is different
ii. Different Content -> Previous Content was Blank
iii. Current Content is Blank - > Previous Content was not
iv. Blank -> Blank
1. No action should be required as the state did not change
f. For an example / more information on how to do this see this link: http://office.microsoft.com/en-us/sharepoint-designer-help/watch-this-run-a-workflow-when-a-specific-field-changes-HA010256419.aspx
8. Hyperlinks made in the WF e-mail editor can be copied and pasted but the pasted version may need the link to be adjusted. Look-ups used in the e-mail editor cannot be copied and pasted.
Tuesday, November 2, 2010
Monday, October 11, 2010
Silverlight User Control Navigation Solution
There are two solution approaches when implementing a navigation solution, the capability to navigate between pages using Silverlight. One approach is to use user controls and is what this write-up focuses on the other approach which was recently added in Silverlight 4. For the most part this is a summary of the demo video provided by Jesse Liberty from Microsoft.
Steps for Creating a User Control Navigation solution
1. Create Silverlight Application
2. Add a new page called NavigationFrame
a. Delete the Grid control LayoutRoot in the NavigationFrame.xaml file
b. In the code behind file add the code below to the constructor to load a default page in this example it is the main page
c. Add a navigate method to change the content displayed in the page
3. Update the App.xaml.cs to load the NavigationFrame Page instead of the MainPage on Application load
a. In the Application_Startup method change MainPage to NavigationFrame
4. Create another Silverlight page called Page_2
5. Add navigation Controls
a. In my case I am using buttons for navigation and added them to both pages (MainPage and Page_2)
6. In the code behind of both MainPage and Page_2 the even handler needs to be added to swap between the target pages
a. Example of code behind for Page_2
Reference: User Control Implementations
Jesse Liberty Demo Video - http://www.silverlight.net/learn/videos/silverlight-videos/using-multiple-pages-part-1/
Slightly Different implementation use a service approach- http://nerddawg.blogspot.com/2008/06/pages-in-silverlight.html
Similar example - http://www.c-sharpcorner.com/UploadFile/nipuntomar/Silverlight07082008154003PM/Silverlight.aspx
Navigation Application (SL4)
Basic implementation write up- http://www.silverlighttoys.com/Tutorials.aspx?tutorial=1
Detailed write-up - http://stuff.seans.com/2010/05/07/silverlight-4-project-types-part-ii-%E2%80%93-silverlight-navigation-application/
Steps for Creating a User Control Navigation solution
1. Create Silverlight Application
2. Add a new page called NavigationFrame
a. Delete the Grid control LayoutRoot in the NavigationFrame.xaml file
b. In the code behind file add the code below to the constructor to load a default page in this example it is the main page
if (this.Content == null)
{
this.Content = new MainPage();
}
c. Add a navigate method to change the content displayed in the page
public void Navigate(UserControl nextPage)
{
this.Content = nextPage;
}3. Update the App.xaml.cs to load the NavigationFrame Page instead of the MainPage on Application load
a. In the Application_Startup method change MainPage to NavigationFrame
4. Create another Silverlight page called Page_2
5. Add navigation Controls
a. In my case I am using buttons for navigation and added them to both pages (MainPage and Page_2)
<button name="buttonSwitch" type="submit" width="75" content="Switch" height="23" horizontalalignment="Left" margin="132,212,0,0" verticalalignment="Top" click="Switch_Click">
6. In the code behind of both MainPage and Page_2 the even handler needs to be added to swap between the target pages
a. Example of code behind for Page_2
private void Switch_Click(object sender, RoutedEventArgs e)
{
NavigateFrame ps = this.Parent as NavigateFrame;
ps.Navigate(new MainPage());
}
Reference: User Control Implementations
Jesse Liberty Demo Video - http://www.silverlight.net/learn/videos/silverlight-videos/using-multiple-pages-part-1/
Slightly Different implementation use a service approach- http://nerddawg.blogspot.com/2008/06/pages-in-silverlight.html
Similar example - http://www.c-sharpcorner.com/UploadFile/nipuntomar/Silverlight07082008154003PM/Silverlight.aspx
Navigation Application (SL4)
Basic implementation write up- http://www.silverlighttoys.com/Tutorials.aspx?tutorial=1
Detailed write-up - http://stuff.seans.com/2010/05/07/silverlight-4-project-types-part-ii-%E2%80%93-silverlight-navigation-application/
Thursday, October 7, 2010
JQuery Resources
With the recent uptick in JQuery as a go to client side technology, I wanted to share these resources I recently found.
This is a nice article describing the role of JQuery and ASP.NET as well as some well-founded conjecture on the future of Microsoft support of JQuery.
http://visitmix.com/Articles/Javascript-Libraries-and-ASPNET
This is an online training guide, I’ve only skimmed the content but it looks like a fantastic resource.
http://jqfundamentals.com/book/book.html
This is a nice article describing the role of JQuery and ASP.NET as well as some well-founded conjecture on the future of Microsoft support of JQuery.
http://visitmix.com/Articles/Javascript-Libraries-and-ASPNET
This is an online training guide, I’ve only skimmed the content but it looks like a fantastic resource.
http://jqfundamentals.com/book/book.html
Wednesday, October 6, 2010
Accessing the UI thread in Silverlight
I’m creating a separate class where I want to move all related Client Object Model (COM) code.
In my case for the COM code to work it must update the UI thread. To accomplish this I had to move the reference from the main page, which was apparently passing through the Deployment object, to explicitly calling the Deployment object.
So in the case of the main page or I suspect any xmal pages code behind use this line of code in the ClientRequestSucceededEventHandler method:
For separate classes to gain access to the UI thread use this line of code in the ClientRequestSucceededEventHandler method:
Reference:
http://www.go4answers.com/Example/error-invalid-cross-thread-access-48335.aspx
Using Silverlight Object Model: http://msdn.microsoft.com/en-us/library/ee538971.aspx
In my case for the COM code to work it must update the UI thread. To accomplish this I had to move the reference from the main page, which was apparently passing through the Deployment object, to explicitly calling the Deployment object.
So in the case of the main page or I suspect any xmal pages code behind use this line of code in the ClientRequestSucceededEventHandler method:
this.Dispatcher.BeginInvoke(updateUI);
For separate classes to gain access to the UI thread use this line of code in the ClientRequestSucceededEventHandler method:
Deployment.Current.Dispatcher.BeginInvoke(updateUI);
Reference:
http://www.go4answers.com/Example/error-invalid-cross-thread-access-48335.aspx
Using Silverlight Object Model: http://msdn.microsoft.com/en-us/library/ee538971.aspx
Labels:
Client Object Model,
COM,
SharePoint,
Silverlight
Tuesday, September 28, 2010
Silverlight Export to Excel
The latest thing I’ve been working on is exporting to Excel from my Silverlight Indicator.
With Silverlight 4 there are two problem domains, In Browser and Out of Browser.
The Out of Browser mode is dead easy using Automation Factory. For it to function it does require the Silverlight App to be locally installed with elevated permissions. There are several examples out there, on the web, of this type of implementation now I leveraged the approach posted by Pradeep at c-sharecorner.com for my application, see his code below. This is a great solution that opens the exported data in an excel spreadsheet.
Solution using Out of Browser Mode
Add reference to Microsoft.CSharp.dll to the project.
Reference links –
Automation API - http://msdn.microsoft.com/en-us/library/ff457794(v=VS.95).aspx
More documentation - http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.automation.automationfactory(VS.95).aspx
A slightly different implementation - http://www.codeproject.com/KB/silverlight/SL4InteropWithExcel.aspx
A similar implementation - http://deepumi.wordpress.com/2010/06/01/export-datagrid-to-excel-in-silverlight-4-0/
Solution using In Browser Mode
With the Out of Browser Domain covered, I needed to tackle the In Browser Domain. To my surprise there wasn’t as many solutions as I thought there would be out there. Exporting a datagrid to excel would seem like a common enough task. Though I did find one gem in the rough Raelango on codeproject.com had posted a nice solution that works great if the columns are TextColumns or are TextBlocks in a template column. It defiantly got me pointed in the right direction. You can see his solution here: http://www.codeproject.com/KB/silverlight/SilverlightDataGridExport.aspx
I took a similar approach though I ended up customizing the code to fit my customized data types. It led to a nice solution which saves to an XML or CSV file based on the user choice through a standard save dialog.
With Silverlight 4 there are two problem domains, In Browser and Out of Browser.
The Out of Browser mode is dead easy using Automation Factory. For it to function it does require the Silverlight App to be locally installed with elevated permissions. There are several examples out there, on the web, of this type of implementation now I leveraged the approach posted by Pradeep at c-sharecorner.com for my application, see his code below. This is a great solution that opens the exported data in an excel spreadsheet.
Solution using Out of Browser Mode
Add reference to Microsoft.CSharp.dll to the project.
using System.Runtime.InteropServices.Automation;
…
///
///This code has been leveraged from the following site:
///http://www.c-sharpcorner.com/UploadFile/pchandraker/1899/
///
///
private void btnExport_Click(object sender, RoutedEventArgs e)
{
dynamic excelApp;
excelApp = AutomationFactory.CreateObject("Excel.Application");
excelApp.Visible = true;
dynamic workbook = excelApp.workbooks;
workbook.Add();
dynamic sheet = excelApp.ActiveSheet;
dynamic cell = null;
int index = 1;
foreach (Employee emp in EmployeeGrid.ItemsSource)
{
cell = sheet.Cells[index, 1];
cell.Value = emp.EmployeeName;
cell = sheet.Cells[index, 2];
cell.Value = emp.EmployeeId;
cell = sheet.Cells[index, 3];
cell.Value = emp.Department;
index++;
}
}
Reference links –
Automation API - http://msdn.microsoft.com/en-us/library/ff457794(v=VS.95).aspx
More documentation - http://msdn.microsoft.com/en-us/library/system.runtime.interopservices.automation.automationfactory(VS.95).aspx
A slightly different implementation - http://www.codeproject.com/KB/silverlight/SL4InteropWithExcel.aspx
A similar implementation - http://deepumi.wordpress.com/2010/06/01/export-datagrid-to-excel-in-silverlight-4-0/
Solution using In Browser Mode
With the Out of Browser Domain covered, I needed to tackle the In Browser Domain. To my surprise there wasn’t as many solutions as I thought there would be out there. Exporting a datagrid to excel would seem like a common enough task. Though I did find one gem in the rough Raelango on codeproject.com had posted a nice solution that works great if the columns are TextColumns or are TextBlocks in a template column. It defiantly got me pointed in the right direction. You can see his solution here: http://www.codeproject.com/KB/silverlight/SilverlightDataGridExport.aspx
I took a similar approach though I ended up customizing the code to fit my customized data types. It led to a nice solution which saves to an XML or CSV file based on the user choice through a standard save dialog.
Thursday, September 23, 2010
Libraries for Client Object Model
Ok this falls in to information I’ve had to look-up a couple times now. So I’m posting this to my blog for quick reference in the future.
Libraries required for SharePoint development using Client Object Model
The two files for Silverlight are:
Microsoft.SharePoint.Client.Silverlight.dll
Microsoft.SharePoint.Client.Silverlight.Runtime.dll
They can be located on the server at %ProgramFiles%\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\ClientBin
For sandbox solutions you need:
Microsoft.SharePoint.Client.dll
Microsoft.SharePoint.Client.Runtime.dll
These are located on the server at %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\ISAPI
Libraries required for SharePoint development using Client Object Model
The two files for Silverlight are:
Microsoft.SharePoint.Client.Silverlight.dll
Microsoft.SharePoint.Client.Silverlight.Runtime.dll
They can be located on the server at %ProgramFiles%\Common Files\Microsoft Shared\Web Server Extensions\14\TEMPLATE\LAYOUTS\ClientBin
For sandbox solutions you need:
Microsoft.SharePoint.Client.dll
Microsoft.SharePoint.Client.Runtime.dll
These are located on the server at %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\ISAPI
Getting the URL Parameter Using C#
As I’ve been working with the SharePoint COM API in Silverlight more things that were really hard to do or nearly impossible to do with SharePoint Designer (SPD) have become easier. One of the first things I need to do was link the Silverlight applications and my existing pages together which I felt was really easy to do by passing Query String Parameters.
This is really easy to do in C# with the Windows.Browser namespace.
Here is the method I use to accomplish this.
Now I can provide whatever key I would like to consume, in my case a row ID so I know which record to query in the SharePoint list.
This is really easy to do in C# with the Windows.Browser namespace.
Here is the method I use to accomplish this.
private string getURLParam(string key)
{
string value = "";
HtmlPage.Document.QueryString.TryGetValue(key, out value);
return value;
}
Now I can provide whatever key I would like to consume, in my case a row ID so I know which record to query in the SharePoint list.
Subscribe to:
Posts (Atom)