Tuesday 12 May 2015

Sharepoint 2013 - How to lookup custom string in workflow task

I'm creating a workflow that assigns a task to a person. After that person completes the task, they are required to input a string of text (a server URL) before they can press "Approve." Once this is done, I want my workflow to assign the next task to another individual, and in the email notification I want to include the server URL the previous person entered. The problem is I haven't been able to find the correct lookup procedure to reference this server URL.
How do I look-up the VM Server URL from the approval screen?
Approval Page asks for Server URL And how do I include that string in the email that gets sent out as the next task?
How do I reference Server URL in SharePoint Designer so the email will display that info?

Update on 1/15

Following Amal's advice, instead of referencing the Current Item ID, I tried to reference the ID matching the output task ID (picture added below). I changed the ID to reference the Task ID from the previous assigned task and now when I complete the first task it seems like the workflow is unable to progress to the next task. It seems to break the workflow. Is there something I did wrong?
I think part of the issue is that the TaskID variable is a string like this (4250c824-d81d-4d4a-b440-924901a1da95), but SharePoint only let's me retrieve it as an integer.
Update 1-15

Solution

The problem was that I was trying to map to the ID field, and apparently that is only for integers. The TaskID is a string and needed to be mapped to the GUID field as a string. This is what worked for me:
Solution

Calling the SharePoint 2013 Rest API from a SharePoint Designer Workflow


Ref: https://sergeluca.wordpress.com/2013/04/09/calling-the-sharepoint-2013-rest-api-from-a-sharepoint-designer-workflow/

At the moment you will find many examples illustrating how to call external JSon web services from  SharePoint Designer 2013 workflows by using the Call activity, but we should keep in mind that the Call action works very well with the SharePoint REST api and this opens the door to plenty of possibilities. However you won’t find many examples illustrating this. Sooo let’s go  ; –)
  • Create an announcements list and let’s say we want to create a workflow that returns the first one by using the REST api.
  • Add a few announcement
  • Start SharePoint Designer 2013 and add a list workflow on this announcement list; make sure the workflow is a SharePoint 2013 workflow
image
  • Test your REST call in the browser, for instance mine is the following :
http://litware/_api/web/Lists/GetbyTitle(‘announcements’)/items
You should get something like this:

image
You will notice that the response is encoded in xml format; since the $json option  is not supported in the SharePoint 2013 REST api, to get the the response in a JSON format you will have to update the Accept and Content-Type http headers of your Rest http call; more specifically :
Accept : application/json;odata=verbose
Content-Type : application/json;odata=verbose
Even if my favorite browser is IE10, I will user Google Chrome to achieve it; start Chrome and install the following Chrome add-in :

image
When the add-in is installed, you should be able to find the following icon that will allow you to set up your headers
image
After typing your request request in Chrome you should get the info encoded in JSON
image
To have a better understanding of structure of the Json response , I usually paste the results in the following JSon parser available online : http://Json.parser.online.fr

image
d/results(0)/Title should be the path of the first announcement title.
Now, let’s get back to our workflow in SharePoint Designer 2013 :
we need to create the Request header, and this is possible by using a Dictionnary :
  • In the existing Stage type Build
image
  • rename the variable dictionnary as JSonRequestHeader :
image
  • Click on this and click on Build your dictionnary ; add the Accept and the Content-Type headers :
image
  • Now let’s focus on the Http request by adding a Call action
image
  • Click on this and paste your http request
image

  • To associate the JSonRequestHeader variable, select the Call action property:
image
  • set the RequestHeaders property to JSonRequestHeader:
image
Click ok.
  • In the  Call action, click on response and associate the response to a new variable : JSonResult (of type Dictionnary).
  • After the Call action add a new Get action.
image
  • Add a log activity and display the myTitle variable in the log :
image
  • The final Stage should look like this :
image
Publish and run the workflow; in the workflow history, you should find your first title :
image

Monday 11 May 2015

SharePoint Workflow Tasklist instance

<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <ListInstance FeatureId="{f9ce21f8-f437-4f7e-8bc6-946378c850f0}"
        Title="FSRWorkflowTasks"
        OnQuickLaunch="TRUE"
        TemplateType="171"
        Url="Lists/FSRWorkflowTasks"
        Description="This list instance is used for FSR workflow Task items"
        RootWebOnly="FALSE" />
  <ContentTypeBinding ListUrl="Lists/FSRWorkflowTasks"
                       RootWebOnly="FALSE"
                       ContentTypeId="0x0108003365C4474CAE8C42BCE396314E88E51F"/>
</Elements>