How to return Pega pyid to javascript async API call

Share with Love

We need to create a case using javascript API asynchronous call, After creating the case we expect the case ID for further processing. please help us how to do that?.

 

I believe there should be a JS function that do what you need, but at this moment I don’t know, so I did it manually.

Use the Show-Property method in your activity to show the property value that will be caught by the javascript function (you can return any property, like the pyID).

Create the following javascript function (your logic will reside in the success callback)

  function callAc() {
    var oSafeURL = new SafeURL("DMOrg-DM-Work-Demo.MyActivity");
    var postData = new SafeURL();
    postData.put("pzPrimaryPageName", "pyWorkPage");
    pega.u.d.asyncRequest("POST", oSafeURL, {
      success: function(o) {
         console.log(o.responseText);
      }
    }, postData);  
  }

Call this function to retrieve the property value from the activity. See below screenshot