Question

How to capture the callback response (failure) to mobile app after sending a REST API call?

Hi,

We have a requirement like we send the DocuSign request from our PRPC V722 application and we check whether the request is successful or not from both Desktop and mobile versions. In Desktop version, we are printing the page level err message after getting the failure response from DocuSign but the same thing we want to achieve it in mobile side as well. I know we can't print the page level messages in mobile but we can give some alert to the user on the failure side. Can someone please help me on how to get the callback response in this mobile context?

Thanks,

Ravi Kumar.

**Moderation Team has archived post**

This post has been archived for educational purposes. Contents and links will no longer be updated. If you have the same/similar question, please write a new post.

Correct Answer
March 8, 2018 - 7:23pm

Depending on what version of Pega you are using, you should be able to create a Read/Write data page and put the value in there.  Then add the data page to the offline data page white list.  Link is in the Offline landing page from the designer studio.  Then you can us

This still seems overboard.  If the data sync succeeds, then the file got to the server.  I still recommend just alerting if the subsequent data sync succeeds or fails.

- James

 

Comments

Keep up to date on this post and subscribe to comments

March 5, 2018 - 2:04am

Hi,

I hope you can use, Status update notifications provide flexibility because you determine when to send the notification. Status update notifications provide information on a task.

March 5, 2018 - 2:27am
Response to SudhakarReddy

Hi,

I didn't get your point. Pls elaborate more on it.

Thanks

Ravi Kumar.

March 7, 2018 - 3:54pm

We are trying with the below option and will let you know.

top.launchbox.PRPC.ClientStore.addAction( undefined, undefined, JSON.stringify(metadata), JSON.stringify(data), writeSuccessCallback, failCallback );

Pega
March 7, 2018 - 4:44pm

I think that is the wrong API to use for this. Please read through the API carefully.

https://pdn.pega.com/sites/pdn.pega.com/files/mobileclient/7312/api/client_api/container_object_client_store.html

I think you want to call launchbox.PRPC.ClientStore.addListener({onStatusUpdate: myListener});

function alertOnNextSuccess() {
    _alertOnNextSuccess = true;
}

function myListener(status) {
    if (status == launchbox.PRPC.ClientStore.Event.SUCCEEDED && _alertOnNextSuccess) {
        _alertOnNextSuccess = false;
       alert("Document uploaded successfully!");
    }
   if (status == launchbox.PRPC.ClientStore.Event.FAILED && _alertOnNextSuccess) {
       _alertOnNextSuccess = false;
       alert("Document has been stored on your device and will be uploaded next time the server is available.");
    }
}
 

Something like this would be much more effective.  Remember to wait until the launchbox API is available before trying to attach the listener.

- James

 

March 7, 2018 - 9:46pm
Response to HALLJ

Thanks James. Let me check this and I will get back.

March 8, 2018 - 6:43pm

Here is the simple option which I am trying for our requirement to show an alert for the connectivity issues while connecting Docusign from Pega

1) Wrote the below script in our mobile script rule's function

------------------------------------------------------

var metadata = {

       "action": "callActivity",

       "activityName": "CheckDSConnectivity",

       "className": "ABC-FW-GHFW-Work",

       "parameters": []

    };

  var data = {

      "pxObjClass": "Work-Cover-"

     };

  top.launchbox.PRPC.ClientStore.addAction("", "", JSON.stringify(metadata), JSON.stringify(data),function() {

    //alert("Success");

    pega.c.actionSequencer.resume();

    datasyncStart();

    //var val2=pega.ui.ClientCache.find("pyWorkPage.DSConnStatus").getValue();

    //alert(val2);

  },function() {

    alert("Fail");

    //datasyncStart();

  });

---------------------------------------------------------------------

2) Activity got called and setting the value of the property based on the success/failure of the connectivity. No issues in this step 

3) After that I would like to capture this property value into a java script variable to show the alert and the next steps. But I am unable to capture the value using the below code after the above lines mentioned in #1. Not sure where I am missing. Pls guide me.

     var val2=pega.ui.ClientCache.find("pyWorkPage.DSConnStatus").getValue();
      alert(val2);

       if(val2=="Fail") { //logic } 

       else{//logic}

Thanks,

Ravi Kumar.    

 

Pega
March 8, 2018 - 7:23pm

Depending on what version of Pega you are using, you should be able to create a Read/Write data page and put the value in there.  Then add the data page to the offline data page white list.  Link is in the Offline landing page from the designer studio.  Then you can us

This still seems overboard.  If the data sync succeeds, then the file got to the server.  I still recommend just alerting if the subsequent data sync succeeds or fails.

- James

 

March 8, 2018 - 8:21pm
Response to HALLJ

Thank you James for the quick response. We do have our own DP's in the mobile stand point. Let me check on how I can put this data into one of the DP's to read it.

March 9, 2018 - 12:22pm

James,

Looks like your sugg did work for us. Testing is in progress to finalize the functionality.