Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Copy filled up Record producer variables to worknotes section

Andrew Kimani
Tera Contributor

Hello,

I want to update script on record producer so that only the fields that are filled in get copied to the technician worknotes

1 ACCEPTED SOLUTION

Sagar Pagar
Tera Patron

Hi @Andrew Kimani,

You need to use the producer scripts and add the non-empty variables to work notes.

 

var strComments = "";

if(producer.variable_name != ""){

strComments += producer.variable_name;

}

if(producer.variable_name1 != ""){

strComments += producer.variable_name1 + "\n";

}

 

if(producer.variable_name2 != ""){

strComments += producer.variable_name2 + "\n";

}

 

if(producer.variable_name3 != ""){

strComments += producer.variable_name3 + "\n";

}

.

.

.

.

so on...

 

current.work_notes = strComments;

 

If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.

Thanks,

Sagar Pagar

The world works with ServiceNow

View solution in original post

3 REPLIES 3

Ravi Chandra_K
Kilo Patron
Kilo Patron

Hello @Andrew Kimani 

Greetings!

You have to write insert BR script for this

refer below threads:

https://www.servicenow.com/community/developer-forum/copy-variables-to-work-notes/m-p/1992735

https://www.servicenow.com/community/developer-forum/help-with-copying-reference-variables-from-a-re...

Please hit the thumb and Mark as correct based on Impact!!

 

Kind Regards,

Ravi Chandra

Sagar Pagar
Tera Patron

Hi @Andrew Kimani,

You need to use the producer scripts and add the non-empty variables to work notes.

 

var strComments = "";

if(producer.variable_name != ""){

strComments += producer.variable_name;

}

if(producer.variable_name1 != ""){

strComments += producer.variable_name1 + "\n";

}

 

if(producer.variable_name2 != ""){

strComments += producer.variable_name2 + "\n";

}

 

if(producer.variable_name3 != ""){

strComments += producer.variable_name3 + "\n";

}

.

.

.

.

so on...

 

current.work_notes = strComments;

 

If my response helps to solve your issue. Kindly mark it as helpful & correct. It will be helpful for future readers.

Thanks,

Sagar Pagar

The world works with ServiceNow

AJ2025
Tera Contributor

I think you can assign it straight to work_notes field. Provided only one field is getting captured.