How to create initiation form for SharePoint2010 workflow part1

January 27, 2012

In the last post, I showed you how to create a simple workflow using Visual studio. In this post, I will show you how to create a custom initiation form. The initiation form is the page that is presented each time that a person starts a workflow manually. The default initiation form is very simple, including only the name of the workflow and two buttons Start and Cancel. Here are the steps to create the custom initiation form.

1. Create the simple workflow just as I did in the last post and then add the Workflow Initiation form from visual studio

2. Add the code that is highlighted in yellow in the form mark-up page.

3.Modify the return statement for the GetInitiationData method as shown below.

private string GetInitiationData()
 {
return CommentTexbox.Text;
 }

 

4. Open you workflow designer pane, and open the log-to-history task properties.

5. Instead of typing “workflow hello world” in the History Description, you set it to InitiationData as show below

6. Deploy your solution and manually trigger the workflow by open the contextual menu(screenshot a) of the item–>Workflows–>Click the YBBEST.SharePointWorkflow.Demo – CustomWorkflow–>you will see your initiation form as below (screenshot b)

(Screenshot a)

(Screenshot b)

7. Type “Custom initiation form” in the comment textbox and start the workflow, after the workflow complete you will see the Custom initiation form in the workflow history.



How to create workflow in SharePoint2010 using visual studio

January 27, 2012

In this post, I will show you how to create a simple sequential workflow using visual studio. You can download a complete solution here.

1. Open visual studio and under SharePoint2010 project template select Sequential Workflow

2. Type your site collection Url and client Next, note that you can only deploy this workflow as farm solution.

3. Give a proper name for you workflow.

4.Associate this workflow with a list or library, in my case I associate it with a custom list called Test.

5. Configure whether workflow triggers , you can choose start manually or automatically when item is created or modified.

6. Drag a log to history activity to the workflow designer pane as shown below.

7. Configure the activity by going to the properties panel and type “workflow hello world” in the HistoryDescription

8. Deploy your solution and we can have test drive as below.

a. Navigate to the test list and add a new item

b. After you click the save button , you will see the workflow is running.

c. Since this is a very simple workflow , after you refresh the browser you can see the workflow status changed from In Progress to Completed.

d. If you click the Completed link , you will your Workflow Hello World in that page.


Populate people picker with current user in InfoPath2010

January 25, 2012

In recent project, we have a requirement to populate people picker with current user in InfoPath2010 form. It is quite easy to do it in InfoPath; however it does not quite work as we have expected. In the end, we have to use a combination of InfoPath and list event receiver to complete this task. Here are the steps to set the current user to the additional stakeholder display name in InfoPath.

1. Add a set a field’s value rule to InfoPath Form load event.

2. Set the condition as below

3. Configure the set field value action as below, userName() is a built-in function in InfoPath2010

4. Publish the form, you will see the current user is populated with the current user name as below, however when you click the save, the user does not get saved. I guess this is due to the fact the people-picker control needs to perform a post-back to do some tricks.But we could not force the control to do it in InfoPath2010 for the automatically populated user , therefore we have to write up an list event receiver to set the current user.

5. In you SharePoint solution, add event receiver.


6. Copy the code to as specified to the screenshot

public
override
void ItemAdding(SPItemEventProperties properties)

       {

           //base.ItemAdding(properties);

           string keyStakeholders = “Key_x0020_Stakeholders”; // this has to be the static or internal name , not the display name

           string seperator = “;#”;

           SPUser user = properties.Web.CurrentUser;

           if (string.IsNullOrEmpty(SPHelper.SafeToString(properties.AfterProperties[keyStakeholders])))

           {

               properties.AfterProperties[keyStakeholders] = seperator + user.ID + seperator + user.Name;

           }

           else {

               SPFieldUserValue fieldValue = SPHelper.GetSPFieldUserValue(SPContext.Current.Web, SPHelper.SafeToString(properties.AfterProperties[keyStakeholders]));

               properties.AfterProperties[keyStakeholders] = seperator + fieldValue.LookupId + seperator + fieldValue.LookupValue + seperator + user.ID + seperator + user.Name;

           }

       }

7. Go to the elements.xml under the new event receiver


8. Change the xml highlighted in yellow

From:


TO


 9. Deploy your solution; it will work like a charm. :)

References:

How to: Create an Event Receiver for a Specific List Instance



Create a “Save and Create New Item” functionality in InfoPath2010 Part2

January 25, 2012

In the last post, I showed you how to configure the form to enable “Save and Create New Item” using Infopath2010. In this post, I will show you some of the problems and solution with enabling this in the form. Once you have enabled this function in the submit option, the save button in the InfoPath top menu will have the same functionalities, this might be confusing to the user as it will work differently from other forms.

To fix it, you can hide save button at the top ribbon and create a new button on the form called “Save And Close Form”. Here are the steps:

1. Go to File–> Advanced form options –>Web Browser and then untick the “Show InfoPath commands in Ribbon or toolbar”

2. Drag a button and label the button as Save and close the form in the InfoPath form

3. Add the following rules to the newly created button. Submit data rule and close form rule.

4. Republish your form and you will see the form as below.


Create a “Save and Create New Item” functionality in InfoPath2010

January 18, 2012

Recently, I got a requirement to create a button on the InfoPath2010 form that save the current item and then open a new form so that they can add another item. To do so in InfoPath2010 is quite easy, here are the steps:

1. Drop a button at the bottom of the form and label it as save and add another Item

2. Right-click the button and select Button Properties.

3. Select Submit from the Action dropdown list.

4. Click the Submit Options and click the Advanced button.

5. Select “Open a new form” from the “after submit” dropdown list.

6. Republish your form, it works like a charm. This option is also available from the form submit options for the Save button in the ribbon.


How to fix “The report server has encountered a configuration error. Logon failed for the unattended execution account.”

January 17, 2012

Recently after I have deployed some SSRS reports to a client staging environment, I got this error as below

After some Goggling and binging, I have found out the problem is that SSRS Execution Account in SSRS configuration manager is set to a normal user account , after the user change its password , it cause the problem above. After some further research, I have found out we do not need to have an Unattended Execution account specified as EnesysRSExtension adheres to SharePoint security and passes through the end user security to maintain permissions. So after I have cleared the SSRS Execution Account, it works like a charm.The unattended execution account refers to the SSRS Execution account from the SSRS Configuration manager as shown below.


References:

The report server has encountered a configuration error. Logon failed for the unattended execution account.

Configuring the Unattended Execution Account


How to invoke Nintex workflow asynchronously using code

January 15, 2012

In this post, I will show you how to invoke Nintex workflow asynchronously using code. Nintex is built on top of SharePoint, so there is no difference between invoking a Nintex workflow and invoking a SharePoint workflow. Below is the code to invoke the workflow.You can download a sample code here.

References

How to check if Workflow is already Running and to Avoid Error Exception from HRESULT: 0×8102009B

Nintex Workflow 2010 SDK – info and download

 


Web Application Scoped Resources

January 13, 2012

When you try to deploy a solution without Web Application Scoped Resources, you will get the following errors:

The solution contains no Web application scoped resource, and therefore cannot be deployed to a particular Web application. It can only be deployed globally.

If you like to deploy the solution to a web application, you need to set the Assembly Deployment Target to WebApplication instead of GlobalAssemblyCache. You can download a deployment script here.

References:

What is a “Web Application Scoped Resource?

A web scoped solution will contain files, features, and assemblies etc that are deployed to specific web applications (or All of them as selected). If there is an assembly destined for the bin directory or a feature set as WebApplication, Site or Web Scoped, then the solution deployment screen will ask you which web application to deploy the solution too (there are other triggers, e.g. App Resource Files (.resx) etc). Of course though, you may have globally deployable files in the solution (e.g. GAC located assemblies) as well as web app scoped resources.

When deploying web app scoped resources, any modifications to the bin folder, app_* folders, web.config etc will only apply to the web apps the solution has been deployed to (or all of them if selected – this option does not include Central Admin or the SSP web app!). Any newly created web apps will not receive these changes UNLESS you have also deployed files into the LAYOUTS/* folder(s) which get merged during web app creation (this is a separate topic all together).

Globally deployed resources are available to ALL web applications on the server, these tend to include farm scoped features, GAC located assemblies and files being deployed into the LAYOUTS/* folder(s).

The difference between deploying “globally” and to all content web apps depends on what you are deploying. If there are web.config changes or web application / site / web scoped features, then these cannot be deployed globally anyway – the option will not be displayed as they must be deployed to a target web application(s).

Issues Deploying SharePoint Solution Packages


How to use SPGridview

January 8, 2012

In this post I’d like to show you how to use SPGridview. In SharePoint2010, if you like to display data in a view like SharePoint, you can use a SharePoint Server control called SPGridview. However, there are a few tips and tricks you need to know to work around some of the known issues of SPGridview.

1. Fixing the group title row disappearance and the sort indicator arrow image, you can find the solution in this blog post.

2. If you turned on grouping, you might get the following error when you do a postback “System.ArgumentNullException: Value canot be null“. The problem happened while rendering the rows again after the postback.

To solve this problem you can find the solution in this blog post and remember to turn off view state after applying this fix.

You can download a complete solution with all of this fixes here.

 

 

 

 


Create a parameterized report using SSRS –Part2

January 8, 2012

In the first part of the series, I have created a parameterized report using SSRS. However, you have to type in the ship Country instead of selecting it from a dropdown list. In this post, I will show you how to create that dropdown list.

1. Create a new Shared dataset called ShipCountriesDS

2. Create a new report dataset using the shared dataset

3. Go to the report parameter and double-click the @ShipCountry and then go to the available values properties tab. Select Get values from a query and select the dataset you created above.

4. Run the report, you will see the dropdown list.

5. Click the view report button and then you will see the report shown below.

You can download a complete solution here.


Follow

Get every new post delivered to your Inbox.

Join 100 other followers