How to send last updated work notes by API ?

DIVI1
Tera Expert

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.

7 REPLIES 7

Rajesh M1
Giga Guru

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.

 

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 ?

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 

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