Server script help for outbound call
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 12:05 AM
Hi,
I have below requirement.
we have a custom table and we are integrating with third party system.
When state is Pending for Int then we are triggering the below assync BR.
try {
var access_Token = new global.myIntegrationUtils().getAccessToken('sys_ of oauth', 'name of Application registry');
var r = new sn_ws.RESTMessageV2('restmessage_name', 'RESTMESSAGE');
r.setRequestHeader('Authorization', 'Bearer ' + access_Token);
r.setStringParameterNoEscape('emp_id', current.getValue("employee_number"));
r.setStringParameterNoEscape('my_id_number', current.getValue("id_number"));
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
responseBody = typeof responseBody == "string" ? responseBody : JSON.stringify(responseBody);
var SAPresposneToUpdate = httpStatus == 201 ? gs.getMessage('Successfully updated in SAP \n {0}', [responseBody]) : responseBody;
current.work_notes = SAPresposneToUpdate;
if (httpStatus == 201 || httpStatus == 200) {
current.state = 3; // if Success = closing request
gs.eventQueue('notigy_requestor', current, '');
} else {
// if there is any error we need to retrigger
state= 5; // this will be moving to retrigger state
current.id_number = ''; //setting blank to this field
gs.eventQueue('notigy_grmember', current, '');
}
current.update();
} catch (ex) {
var message = ex.message;
}
I am not understanding how to retrigger the Business rule and handle the errors.
errors can be as below:
employee number locked = we will get status code = 400
if we give same id number for 2 request = we will status code= 400
we need to correct this and retrigger.
Please help me if anyone have any idea how to handle error codes and retrigger my Outbound integration.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 01:21 AM
Hi @Amit Verma
It should be corrected manually and need to retrigger.
You have mentioned
you can make a function to call your REST API code and call it recursively. You can put a condition that until you don't get the status code as 200, it should try.
I am not understanding how to retrigger. please help.
How to achieve the below points. Please share me sample code .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 01:38 AM
So you want to keep a track of those records where you encountered a failure and retrigger the business rule for them ?
Thanks & Regards
Amit Verma
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 01:50 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 02:12 AM
Is their any choice in your state field which we can set on failure like Int Failed ? Also, the third party application is responsible to change the state to Pending for Int ?
I am thinking if we can mark the state of the failed records to some state so that we could do the manual corrections and the state changes back to Pending for Int, the Business rule can retrigger on it's own.
Please mark this response as correct and helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-08-2024 02:17 AM - edited 02-08-2024 02:19 AM
Hi Amit,
yes we have configured this state call pending for int only to trigger business rule for calling outbound call.
i have created a state called : retrigger
when ever failure happens .
but I am not understanding how to retrigger my business rule on update