Why 2 journal entry records are created when work_notes are updated using before business rule

Viswanatha Red3
Mega Expert

Hi All,

For each note, I would like to add a hash tag. For achieving this, I have have created a before business rule on the task form and appending the work_notes with tag name

BEFORE business rule (Order 100)

 

(function executeRule(current, previous /*null when async*/) {

// Add your code here
current.work_notes = current.work_notes+"\n#1234Viswa";
})(current, previous);

But when I enter a work note, I see two entries. One with the entered value, the other with the hastag. Is it possible to have only journal record entry ?

find_real_file.png

Regards

Viswa

7 REPLIES 7

Viswanatha Red3
Mega Expert

Hi Harsha,

 

setJournalEntry, didn't work in any scoped applications. Hence moved the code to Global scope, but I am still having the same issue. 

Now with the above code, I have two journal entries, one with original value and the other only with "#1234Viswa"

 

Regards

Viswa 

Can you try like this

(function executeRule(current, previous /*null when async*/) { 
// Add your code here 
current.work_notes = current.work_notes+"\n#1234Viswa"; 
current.update();
})(current, previous);

if the above solution is not working , can you give a try with onSubmit client script

 

Sample code:

 

function onSubmit() {
   //Type appropriate comment here, and begin script below
	

	g_form.setValue('work_notes',g_form.getValue('work_notes') + "\n#1234Viswa");
   
}