Monday, June 6, 2016

Consuming Protected Rest Service in Process Cloud Service Form Rules.

Recently, I was working on a customer requirement where in I had to invoke protected REST service that returns JSON and pre-populates the Web Form. 

The below shows the steps on achieving the same.

1.     In Process Cloud (BPM) Workspace, Select Administration and Credentials
2.     In Credentials, create a new Credential for Forms Rules. The credentials should be of type "Web Form Rest Services Credential". Give the necessary details like base url, user name & password & Click Save & Log out of the work space





3.     Login to the composer and go to your web form.

  1. Click on new/existing form rules & use the below code



if(buttonClickedr.clicked) //On Click on Button
{
try {
      var uri = "https://www.protectedrestservice.com:80/PCS/previousOrder?supplierId=6666&storeId=2";
var data = http.get(uri);

      }  catch (e) {
        Desc.value = 'got exception' + e ;
   }

Desc.value = data;

Make sure the url matches the key that you had created in the workspace.

Test the form rule. You should be able to see the response from the REST invocation into the description field.


No comments: