SharePoint Designer Workflow using Call http Commands

What’s this Blog about?

Karen Adkins

This blog lists some helpful tips and tricks about using the http GET and http POST. We’ll  walk through creating a SharePoint Designer Site Workflow that loops through an existing orders list to find pending orders which are added to a Historical Pending Orders List.

About Me

I know enough to be dangerous in the development world. However,  my current role does not allow for much development/power user type activities.  I know a little about json, xml, ajax calls, javascript.  To be effective, I need to search the internet for more answers!

 

Call http GET and POST Lessons Learned

  • $top=4999. By default There is a default limit of 100 items returned on REST calls in SharePoint…to overcome that limit you can add $top=4999 to the end of your query.
  • A lot of the blog posts have you looking for the unique list id. Getbytitle(‘NameOfList’) worked great for me.  I didn’t have to mess around with finding the GUID.
  • Make sure to set the Advanced Properties on the Calls.
    • For the GET – Set Request Headers using a variable of type dictionary.
    • For the GET – set the results/dataset in a variable of type dictionary.
  • When/if you want a record/item count, use the results variable in the Advanced Properties of the call GET.

  • Calculated fields do NOT work as filter criteria
  • When adding a record to List B based on List A values, if there are null values, the POST fails. No list item is written.
  • Null date fields default to a value of 1/1/0001 12:00:00 am
  • $expand – used for lookup fields.
  • http POST worked using __metadata – enter metadata and __metadata. Note the 2 _ before metadata
  • Postman or another REST API tool is good to have to ensure your calls are syntax correct and bringing back the results you want.

Workflow Scenario

Our client needed to keep track of orders in a pending state.  They wanted to look at the number of orders and which orders were in a pending state last month, last week, etc.  How many Pending Orders in Week 1, Week 2, etc.  The solution needed to run every 7 days and not require user intervention.  The business users will be looking at the reports.  That is it.

Workflow Steps

 

  1. Created a Historical Pending Orders Custom List with the following fields:

 

 

 

Note:  We didn’t need a duplicate of the Orders Status List.  If the client wanted more information about the order, the client will look at the Orders Status List.

  1. Postman or other type tool – create GET call and test.

 

 

 

  1. SharePoint Designer Workflow:
    1. Create a Site Workflow since we are not starting the workflow on an item change or addition.
    2. Stage: Get Order List
      1. Create Request Headers (this sets the header parameters so that json results are returned)
        1. Accept:
        2. Content-Type:
      2. Call http GET
  • Highlight the call and either use the drop down option to select properties or click on Advanced Properties in the ribbon.
    1. Set Request Headers
    2. Set Return Results
  1. Get the dataset results
  2. Count Items command. Make sure to use the Results variable that is set in the Advanced Properties.  In our case, it is JSONResults.   Make a variable recordCount which is used to loop through the Orders List
  3. Create Log Message that includes ResponseCode, Count of Items, etc.
  • Transition Stage – End of Workflow
  • SAVE Workflow and Test.
  1. Stage: Get Order List
    1. Add setting the index to 0
  2. Loop: Read Through for Pending Orders
    1. Loops while index < RecordCount
    2. Get d/results:ItemColumn from JSONResults output to variable – do this for each of the Historical Pending Order Item Columns that we will be updating.
  • Set parameters for POST
  1. Call POST
  2. Add 1 to index

 

End of Workflow

 

 

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s