Thursday, February 26, 2015

SharePoint 2013 timer job workflow to process items in a list: lessons learned

Here are some gotchas,   
  • could not get a null date filter to work 
  • only the request header, ResponseContent, and responseCode is needed to use the web service activity
    • Use HTTP Get
    • set header
      • ACCEPT:  application/json;odata=verbose
      • Content-Type: application/json;odata=verbose
      • not needed:  X-RequestDigest: $("__REQUESTDIGEST").val()
    • get d/results
    • the values for each items needs a parenthesis like Get (0)/fieldname 
  • not all fields are accessible from the normal json call for example:  http://yoursiteURL/_api/web/lists/getbytitle('ListTitle')/items
    • by default it will only return 100 so can add ?$top=5000
    • so you can call the web service to return all string by calling the web service with the url for each item:
      • ([%Variable: index%])/FieldValuesAsText/__deferred/uri  
        • This will be the url to call to return fields as text like the people names for emails, etc
  • A good way to view the fields for the json call that i used:
    • firefox
    • add-ons:  i used the following  
      • JSONView 0.9
      • Modify Headers 0.7.1.1
    • only thing to make this work is to click on the options on the Modify Headers options, then add the action Modify, the name is Accept, the value is application/json;odata=verbose
    • all you have to do now is just call the service and the json data will display in firefox. 
      • SWEET!
      • this is very useful for field names
  • Have fun folks.  
    • if questions, let me know.  this is one of the best new features of SharePoint 2013.