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.

work note do not display variables values.

keshav77
Tera Contributor

 I am writing run script to display  work  notes which hold variables value if stage is planning  in release management.

 


var applications = current.applications;
var business_application_bai=current.business_application_bai;
var name = current.name.toString();
var names = current.names.toString();
var version = current.application_version.toString();



target.work_notes=applications+'|'+business_application_bai+'|'+name+'|'+names;
 
help with this
 
 
2 REPLIES 2

Mani A
Tera Guru

 

var applications = current.applications;
var business_application_bai=current.business_application_bai;
var name = current.name.toString();
var names = current.names.toString();
var version = current.application_version.toString();


var x = applications + '|' + business_application_bai + '|' + name + '|' + names;


if (current.work_notes) {
current.work_notes += '\n' + x; //add to existing data
} else {
current.work_notes = x; 
}

current.update();

RikV
Tera Expert

What are the field types of the applications and business_application_bai? As it might need to be stringified also, or fetched with the getDisplayValue('field'). Right now you are directly assigning the field object, which does not automatically convert into a (string) value or something, so will not work when constructing string x. 

 

Also, you dont have to append string x to current.work_notes. Just doing current.work_notes = x and then a update will work fine and sort it out for you, and just adds it as a new work note.

 

        var applications = current.getDisplayValue('applications');
        var business_application_bai = current.getDisplayValue('business_application_bai');
        var name = current.name.toString();
        var names = current.names.toString();
        var version = current.application_version.toString();

        var x =
            applications +
            '\n' +
            business_application_bai +
            '\n' +
            name +
            '\n' +
            names;

        current.work_notes = x;
        current.update();