Friday, July 1, 2016

Create views based on workflow status

To create a view to show all the completed approval items in a list/library.


- Click on List/Library tab
- Modify View
- Scroll down to add filter on workflow name
- In the filter value type 16 to filter all the approved items.





For other status, below is a list.


Status
Value
Not Started
0
Failed on Start
1
In Progress
2
Error Occurred
3
Canceled
4
Completed
5
Failed on Start (retrying)
6
Error Occurred (retrying)
7
Canceled
15
* This is defined but I don’t think this value is used
Approved
16
Rejected
17

Wednesday, June 22, 2016

Enabling the edit in Manage User Properties page in IE 11

I was asked to hide some of the fields from appearing in the edit profile page. I knew where exactly to go to(CA->Application Management->Manage Service Application->User Profile Synchronization->Manage User Properties) change it but the page didn't show up any link for that field to edit it. In IE 11 you have do some settings to be able to make the Edit link available.


Follow the steps below to do the same.


- Open you manage user properties page in IE.
- Click on the gear icon on the top right.

- Select "Compatibility View Settings".
- Click Add.

Thursday, June 16, 2016

Sign in as another user in SharePoint 2013

If you have logged into a server using a farm account and want to test your user profile page there is no OOB Sign in as different user option in SP2013. OR if you want to open CA from your local machine using Farm account, follow the below quick step.
Solution: To the URL append _layouts/closeconnection.aspx?loginasanotheruser=true

Ex: http://Centraladmin:5555/_layouts/closeconnection.aspx?loginasanotheruser=true

Monday, June 6, 2016

Setting Hyperlink column with the URL and Description text from SharePoint Designer

My scenario was to provide a hyperlink to the task form from a SharePoint list.

Solution: Created a hyperlink column in a SharePoint list. Since we cannot have a URL to task form until the task is assigned. I have to set the hyperlink field inside my workflow. The challenge was to set both description and link to the form.

Follow the steps below to achieve this in SharePoint workflow designer.

- Set the hyperlink column as below. URL followed by a comma and a description text.


- You will see the column look as below.

Friday, April 22, 2016

Auto Populating Due Date on the SharePoint/Infopath form to 5 business Days

This is done after the SharePoint list is customized using InfoPath.

Follow the steps below to prepopulate the Date & Time field to 5 business days from today.

- Add a text field and remove it to appear on the form.
- Under Data tab add the rule below to set the textbox with below formula.

(number(substring(today(), 9, 2)) + number(number(substring(today(), 1, 4)) - floor((14 - number(substring(today(), 6, 2))) / 12)) + floor(number(number(substring(today(), 1, 4)) - floor((14 - number(substring(today(), 6, 2))) / 12)) / 4) - floor(number(number(substring(today(), 1, 4)) - floor((14 - number(substring(today(), 6, 2))) / 12)) / 100) + floor(number(number(substring(today(), 1, 4)) - floor((14 - number(substring(today(), 6, 2))) / 12)) / 400) + floor(31 * number(number(substring(today(), 6, 2)) + 12 * floor((14 - number(substring(today(), 6, 2))) / 12) - 2) / 12)) mod 7 + 1

NOTE: This not my formula and I lost the URL where I found this. Please if anyone knows it, please cite it here.

- Above formula returns 1 if Sunday, 2 if Monday and so on. So in my case to add 5 business days, I added 3 rules, one for weekday, one for Sunday and one for Saturday.
1. Weekday Rule: textbox = 2 or textbox =3 or textbox =4 or textbox = 5 or textbox =6
set due date = adddays(now(),7).
Check Don’t run remaining rules. This is very important
2. Sunday Rule: textbox = 1
set due date = adddays(now(),5)
Check don’t run remaining rules
3. Saturday Rule: textbox = 7
set due date = adddays(now(),6)
Check don’t run remaining rules

All the above rules are calculated on form load.

Friday, April 15, 2016

Create views based on workflow status

The workflow Status values will be stored as numbers instead of string values. So to create a view to see all the "Completed" workflow tasks, go to modify the view and apply the filter as shown below


For other status follow the below table

  Status
Value
Not Started
0
Failed on Start
1
In Progress
2
Error Occurred
3
Canceled
4
Completed
5
Failed on Start (retrying)
6
Error Occurred (retrying)
7
Canceled
15
* This is defined but I don’t think this value is used
Approved
16
Rejected
17



Adding more than 5 fields in InfoPath Rules

It looks like InfoPath doesn’t allow more than 5 fields in a rule with “And” being greyed out after that. But you can add as many (at least I have added 35 fields) in a rule with below approach. In my scenario all my fields were named with numbers. But it works the same with any type of field.
Below are the instructions.

- Add the 5 fields(including 5th).
- On the last field, change it to “The expression". Copy the expression and type “and” or “or” and paste it.
- Now change the name of the field and so on add all the fields.

Thursday, April 7, 2016

Setting Due Date (in business days) inside the workflow



We had a requirement to assign a task to the user but the due date has to be set to 5 business day (Just excludes Saturday & Sunday. Other company holidays are not considered) from the day task will be assigned. So the below code was added in "Before a Task is assigned" section in approval workflow.


The first line is self explanatory. In Second line copy the CurrentDate (long date) to a string variable called Variable:StringCurrentDate. Now the value of the string will of the format Thursday, April 07, 2016. Using copy function copied the first 3 characters which will be Mon, Tue, Wed etc. If the value is Mon, Tue.... Friday add 7 days, if Sun add 5 and if Sat add 6.


Then use the variable:date to set the task:due date.




Thursday, March 31, 2016

SharePoint Workflow Unique Email for Reassign and Change Request



One of the requirements I worked on recently required different emails(body of the email) to be sent and also the people who has to be cc'ed were different depending on what is selected. For example if the user selects "Reassign" an email has to sent to the reassigned person & CC his manager. If "Change Request" is selected email has to be sent with different text saying its a change request(I renamed it to "More Information" in my case).


Couple of blogs suggested to use Task Name property to see if it has(contains) "change request" word etc. But I wanted more flexibility in my solution and also some of the properties I wanted to set in my workflow were "Task Name" and "Due Date".


So after several testing and research below is my approach. This is using SharePoint 2010 workflow. Doesn't work in SharePoint 2013 workflow.


1. Open your designer, connect to site and click on "Workflows" from left navigation. Select the list workflow and click on the list to which you want to attach the workflow. Give a name to the workflow.






2.Inside your workflow add a "Start Custom Task Process", provide "these users" with the user names to whom you want to assign a task to. Then click on "Task(1)"

3. In "Task Form Fields" click on "New" and create a new field. In my case its WOStatus(type string) as shown below.


3. In "Settings" section check the box for "Reassign" and "Change Request".

4.  Publish your workflow once so that a task form is created.

5. Open your task form(InfoPath form).Now we'll have to set buttons with value. I mean click on "PAGE DESIGN" tab and from the "view" drop down click on "ReassignTask". Click on the "Send" button and from "PROPERTIES" tab click "Manage Rules". Here we are setting the WOStatus field to "Reassign" using some InfoPath rules. In a few minutes you will see why and where we can use this.

6. Similarly go to "Change Request" view. Click on the "Send" button and set the value for "WOStatus" as "Change Request".

7. Publish the workflow.

8. Now go inside the workflow by clicking on "Task(1)" and select "Change the behavior of a single task" as shown below.








9. Here since its Custom Task process, you will see all the sections are blank and each section is self explanatory by the one line description in the beginning.

10. The first step here is interesting as we'll be going to "When a Task Completes" section first. Because the values we set in the InfoPath will be lost after this step. So we will use a workflow variable to capture the value which is set by either "Reassign" or "Change Request".

11. Now we' can set our "Task Name" in "Before a Task is Assigned" section. (This is optional. I did this as I wanted my task name to be unique depending on whether its a reassign task or change request or initial task assignment.).

12. Now the actual part - to send the different emails depending on what is selected. Same as above to set the Task Name, Use the WOStatus to send the emails as shown below


There could be other ways to do this. But I found this method to be more flexible in setting the fields like task name, due dates(one of my requirements was to set different due dates. For example: For :"More Information"(Change Request) only 2 days has to be given if Reassign or initial task assignment 5 days)etc.