Monday, October 24, 2011

SharePoint Designer workflow keeps running old version

If you do some changes in the workflow and publish it again, sometimes the changes won't get reflected on the site. Workflow keeps running the old version since it does not update the dll. This is basically due to a mismatch between the server's activity and the SPD client's cached activity. To fix this problem its a good idea to clear your SPD activity cache whenever you update your activities DLL on the server.

To clear the SPD activity cache:

1. Close SPD.
2. Open “My Computer”.
3. Go to %System Drive%\Documents and Settings\%user%\Local Settings\Application Data\Microsoft\WebSiteCache (If you are running Vista, that path is different - look for %System Drive%\Users\%user%\AppData\Local\Microsoft\WebSiteCache).
4. Go to a directory that looks similar to the name of the website you were connecting to. (Alternatively, you can just delete all these directories and everything should work when you boot SPD).
5. Delete the assembly with the name similar to the one you are changing.
6. Boot SPD.
7. You can now work with your updated activity.

Your workflow will start working as expected !!

Send mail functionality on infopath hyperlink

Infopath can not provide send e-mail functionality similar to sharepoint designer workflow. But here is the workaround for this,

Insert hyperlink control on form and add MailTo protocol into data source part of the hyperlink.

e.g. concat('mailto:',my:Author/pc:Person/pc:AccountId,'?subject=Subject line &','body=Text goes here....')

mailto supports url encodes for inserting special characters. E.g.Use %26 to insert &, %23 to insert #, %24 to insert $ etc...

Please see below links for
more url encodes,

http://www.w3schools.com/tags/ref_urlencode.asp

more Mailto syntax,

http://www.addressmunger.com/mailto_syntax_tutorial/

Workflow Clean up job

By default, Microsoft SharePoint Server 2010 runs a daily Workflow Auto Cleanup job to permanently delete workflow instances and related task entries that still exist 60 days after a workflow is completed or canceled. Workflow history items themselves are not deleted, but the entry point to view them on the status page for a particular instance of a workflow will no longer be available. You can disable the Workflow Auto Cleanup job if you want to keep workflow data available longer. However, as with any SharePoint list, as the workflow history and task lists grow in size, site performance may be compromised. If you are concerned about the size of these lists, keep the Workflow Auto Cleanup job enabled. Whether or not you keep the Workflow Auto Cleanup job enabled, you can create a separate history and task list for each workflow association to distribute items across lists.

To disable automatic workflow cleanup

1. Verify that you have the following administrative credentials:

- To disable automatic workflow cleanup, you must be a member of the Farm Administrators SharePoint group.


2. From the Central Administration Web site, on the Quick Launch, click Monitoring.

3. On the Monitoring page, in the Timer Jobs section, click Review job definitions.

4. On the Job Definitions page, in the Title column, click the Workflow Auto Cleanup link that is associated with the Web application for which you want to disable automatic workflow cleanup.

5. On the Edit Timer Job page, click Disable to disable the Workflow Auto Cleanup feature.

for more information, see

http://technet.microsoft.com/en-us/library/ee662522.aspx

Calculated column for Active/InActive depending on end date

Create Calculated column in list and paste the below formula there,

=IF(OR([End Date]="",[Today]<[End Date]), "Active", "Expired")

This can be useful to mark the item which has reached its expiration or end date.

Please find more formulas for Calculated field here,
http://msdn.microsoft.com/en-us/library/bb862071.aspx

Infopath - Set rule on people picker

I don’t think it’s possible to add action rule to this control directly. But you can add rule to it indirect. Here is the main logic in my opinion.

1. Add a “People Picker” to the Form;

2. Add a “Text Box” control to the Form, and set its properties as following:

a. Default Value: AccountId. (you specify the default value to the People picker field)

b. Refresh value when formula is recalculated : checked.

c. Display: Read-only. (Make it read-only, so that the user cannot change its value by UI )

3. Add Rule to the “Text Box” control. When “This field changes”, do “set a field’s value ”, or submit data.