Copy field change values on additional comment

Souvick6917
Tera Contributor

Hello All

I have a requirement to copy filed values changing on the form to capture n Additional comment as present on the form.

For example, I have 2 fields. These two are reference fields. Whenever we are changing the values of these 2 fields the values should be captured on the Additional comment(customer visible) part.

 

Please guide me to achieve this requirement.

 

Thanks in Advance

Souvick

1 ACCEPTED SOLUTION

@Souvick6917 , try to update directly then.

 

 

var field1 = current. < fieldname > ;
var field2 = current. < fieldname > ;
current.comments = 'Field 1 is :' + field1+','+ 'Field 2 is :' + field2;

 

 

 

Let me know if this also dosent work 

 

Please check and Mark Helpful and Correct if it really helps you.

Regards,

Swathi Sarang

View solution in original post

4 REPLIES 4

swathisarang98
Giga Sage
Giga Sage

Hi @Souvick6917 ,

 

You can create a before update business rule and give condition as field1 changes and field2 changes , select advance and in script write something as below,

 

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

    var field1 = current. < fieldname > ;
    var field2 = current. < fieldname > ;
    current.comments.setJournalEntry(field1, 'System'); // i have added system so that it will show updated as system you can remove it.
	current.comments.setJournalEntry(field2, 'System');


})(current, previous);

 

 

Please check and Mark Helpful and Correct if it really helps you.

Regards,

Swathi Sarang

Hi Swathi

I have tried the above script but after saving the BR and running validation on the form , I am getting an error as below error message

Error Message

 

Function setJournalEntry is not allowed in scope sn_bom_payment

 
We have the form on a scoped application, any idea to get over this error.
 

@Souvick6917 , try to update directly then.

 

 

var field1 = current. < fieldname > ;
var field2 = current. < fieldname > ;
current.comments = 'Field 1 is :' + field1+','+ 'Field 2 is :' + field2;

 

 

 

Let me know if this also dosent work 

 

Please check and Mark Helpful and Correct if it really helps you.

Regards,

Swathi Sarang

I need to modify the script to few things but thanks a lot Swathi for providing the structure of the script.

 

Regards

Souvick