Updating Content Approval Status using SharePoint Designer 2013 Workflow

I recently changing Akumina’s InterChange to work with SharePoint 2013 SharePoint Designer workflow but ran into issue that I cannot update the content approval status (_ModerationStatus field) via Designer workflow using builtin update list item activity.  Here is the step-by-step instruction to update content approval status from SharePoint Designer workflow using CallHTTP activity.

  1.  Activate “Workflows can use app permissions” from Site Collection –>Site Settings–>Site Actions–>Manage Site Features
  2. Go to Site Collection –>Site Settings–>Users and Permissions then click Site app permissions and then copy the GUID from workflowappperm
  3. Go to site Collection URL ~/_layouts/15/appInv.aspx  complete the following values
    1. AppId: value copied from above step
    2. Title: workflow
    3. AppDomain: yourdomain (or machinename)
    4. Redirect URL: http://YourDomain (or  http://<machinename>)
    5. Permission Request XML:

      <AppPermissionRequests><AppPermissionRequest Scope=”http://sharepoint/content/sitecollection/web” Right=”FullControl” /></AppPermissionRequests>appinv

    6. Click Create.  You will be promted with dialog.  Click Trust it
  4. Launch the SharePoint Designer and Create a List Workflow (Same applicable for Reusable or Site Workflow)
  5. From the designer action drop the Build Dictionary Activity and name id “ApprovalRequestHeader” add the following fields
    Name Type Value
    accept String application/json;odata=verbose
    content-type String application/json;odata=verbose
    X-HTTP-Method String MERGE
    IF-MATCH String *
  6. From the designer action drop the Build Dictionary Activity and name id “RequestApprovalMetadata” add the following fields.  Note that Approval Required field must be turned on for this value to appear
    Name Type Value
    type String SP.Data.<LISTNAME>ListItem

    You can get this value by browsing to http://<yoursite>/ _api/web/lists

    The value should be from listitementitypefullname

    Build Metadata Dictionary

  7. From the designer action drop the Build Dictionary Activity and name id “RequestApprovalParam” add the following fields
    Name Type Value
    __metadata Dictionary Variable: ApprovalMetadata

    Refer to workflow parameters named ApprovalMetadata created in previous step

    OData__ModerationStatus Integer 0You can get the field type/name by browsing  http://<yoursite>/_api/web/lists/getbyTitle(‘<LISTNAME>’)/items

     

  8. From the designer action drop the CallHTTP activity and set the propertiescallhttp
  9. Publish the workflow
  10. To package and deploy https://msdn.microsoft.com/en-us/library/office/jj819316.aspx