- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-26-2022 05:11 AM
Hi All,
I have a requirement where I need to send an update back to third party when worknotes are changed. I created the business rule with condition "current.work_notes.changes()"
BR is getting triggered but when I am capturing the fields in body nothing is getting captured and it is not going inside try. Directly going in catch so not sending any data. Below is the BR. I captured work notes in var notes and getting log: "Notes 26-08-2022 17:26:15 - Shivani Malhan (Work notes)
test7"
Then in var body i am giving the fields which i want to send. and in logs I am getting: "Body [object Object]"
Business Rule:
(function executeRule(current, previous /*null when async*/) {
var sysid = current.sys_id;
//gs.log('sysid '+sysid);
var notes = current.work_notes.getJournalEntry(1);
gs.log('Notes '+notes);
var body = {
"number": current.number.toString(),
"state":current.getDisplayValue('state'),
"work_notes":notes,
};
gs.log('Body '+body);
try {
var r = new sn_ws.RESTMessageV2('xyz', 'Default PUT');
r.setRequestBody(JSON.stringify(body));
var response = r.execute();
var responseBody = response.getBody();
var httpStatus = response.getStatusCode();
gs.log('response'+ responseBody);
gs.log("status1234"+ httpStatus);
gs.log('Body'+ r.getRequestBody());
}
catch(ex) {
var message = ex.message;
gs.log('fail');
}
})(current, previous);
Need help!!
Thanks,
Shivani
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-26-2022 05:50 AM
Are you sure above is the complete code snippet that you are using?
because in the exception it says "response" is not defined. but actually we defined var response
if you are using other line of coding make sure you define the variable before using it.
Thanks & Regards,
Vasanth
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-26-2022 06:16 AM
Thank you so much. Issue resolved. There was an error in BR. Instead of response in var, I was using responsew (typo error)
resolved the issue
Thanks,
Shivani
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-26-2022 06:20 AM
Please close this thread by marking an answer correct
Thanks & Regards,
Vasanth