How to send worknote (if it is updated ) using business rule

String
Kilo Sage

Hi ,

am using business rule to capture the current work note as below code ,But requirement is when work note updated than only have to capture the work note and send to 3rd party tool  .please guide me 

current.work_notes.getJournalEntry(1)

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

@String 

You can have condition in BR

current.work_notes.changes()

To get the latest work notes value use this

current.work_notes.getJournalEntry(1)

Regards
Ankur

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader

View solution in original post

13 REPLIES 13

Basically you want to get the record that was before that,I think you have write a script like below

 

var grInc = new GlideRecord('sys_journal_field');
grInc.addQuery('element_id',current.sys_id); // Adding filter to find current incident
grInc.addQuery('element','work_notes'); // Adding filter to fetch only Worknotes
grInc.addQuery('value','!=',current.work_notes.getJournalEntry(1)); 
grInc.orderByDesc('sys_created_on');
grInc.query();
if(grInc.next())
{
gs.info(grInc.value);
}

 

This script will give you the previous record .

 

If you want to test in background scripts use below

 

var grInc = new GlideRecord('sys_journal_field');
grInc.addQuery('element_id','471bfbc7a9fe198101e77a3e10e5d47f'); // Adding filter to find current incident
grInc.addQuery('element','work_notes'); // Adding filter to fetch only Worknotes
grInc.addQuery('value','!=','WW'); 
grInc.orderByDesc('sys_created_on');
grInc.query();
if(grInc.next())
{
gs.print(grInc.value);
}

 

Regards

Pranav

Hi ,

when we are using  current.work_notes.getJournalEntry(1)

iam getting output as :06/12/2020 12:46:34 - User name (Work notes)
test7

 

But my work note is :test7 (getting additional string like time and user name ),is tehre is way to eliminate and print only work note value .!

These things come from a script include so you have to modify that but I won't recommend modifying OOB script includes

okay, In sys_journal_field table values are test 6

but when iam fetching from current.work_notes.getJournalEntry(1) iam getting  06/12/2020 12:46:34 - User name (Work notes) test6

 

So in the above script validations are not  happen as expected .!

Hi @Pranav Bhagat ,

Iaam going to trim my wroknote and send that value to the above script and it works thanks for ur help