How to send last updated work notes by API ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2023 07:50 AM
Hi,
It's little bit complicated, especially for me, cause I want to sent last updated work notes to other system using API, and I have something like that in the Business Rule:
var worknotes = current.work_notes.getJournalEntry(1);
var onlyNotes = worknotes.split("(Work notes)\n");
var lastWorknote = onlyNotes [1];
but the problem is, even if the work notes field doesn't has been updated, the last updated one was sent again...
so here is my question: how to add condition only for that one field, value will be sent when the field has been updated.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-08-2023 08:13 AM
Hi Divi
Can you try to add IF statement like below before setting value in your variable
if(current.work_notes.changes())
If helpful mark answer as correct
Regards
Rajesh M.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2023 12:56 AM
unfortunately the other system got message from this field as "undefined"
here is a code:
if(current.work_notes.changes()){
var worknotes = current.work_notes.getJournalEntry(1);
var onlyNotes = worknotes.split("(Work notes)\n");
var lastWorknote = onlyNotes [1];
}
var r = new sn_ws.RESTMessageV2('API Integration','API POST');
r.setStringParameterNoEscape('u_work_notes', lastWorknote);
So what do you think about it ?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-09-2023 01:09 AM
You will have to create multiple business rules or might have to divide code into 2 business rule. One for worknotes and other for the fields and condition you are currently sending data to an api
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-12-2023 11:03 AM
The variable lastworknote should be initialized outside IF block, Once try the below code
var lastWorknote = '';
if(current.work_notes.changes())
{
your lines of code
lastWorknote = onlyNotes[1];
}
REST CALL