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.

Update on work notes returning as 'Undefined'

matthew_hughes
Kilo Sage

I've written the following script within my business rule to state that a field has been updated alongside the name of the Business Application Steward:

 

(function executeRule(current, previous /*null when async*/) {
var businessApplicationSteward = current.getValue('u_cmdb_data_steward');
var technicalApplicationOwner = current.getValue('u_custodian');
if ((current.u_business_application_type.changes() && gs.getUserID() == businessApplicationSteward)) {
current.work_notes = 'The Business Applicaion Type field has been updated by the Business Application Steward '+ businessApplicationSteward.name;
}

})(current, previous);

 

However when I do that, I get the following outcome:

 
The Business Applicaion Type field has been updated by the Business Application Steward undefined
 
I was just wondering if somebody could explain what I'm doing wrong and I need to do to get the display name of the user
1 ACCEPTED SOLUTION

matthew_hughes
Kilo Sage

I've found the solution by doing the following:

 

//If the Heritage field changes and was updated by the Application Service Steward
if ((current.u_heritage.changes() && gs.getUserID() == applicationServiceSteward)) {
current.work_notes = 'The Heritage field has been updated by the Application Service Steward '+ applicationServiceStewardName;
}

View solution in original post

6 REPLIES 6

sushantmalsure
Mega Sage

replace your line of adding worknote with following:

 

current.work_notes = 'The Business Applicaion Type field has been updated by the Business Application Steward '+ current.u_cmdb_data_steward.name;
If my answer has helped with your question, please mark my answer as accepted solution and give a thumb up.
Regards,Sushant Malsure

matthew_hughes
Kilo Sage

I've found the solution by doing the following:

 

//If the Heritage field changes and was updated by the Application Service Steward
if ((current.u_heritage.changes() && gs.getUserID() == applicationServiceSteward)) {
current.work_notes = 'The Heritage field has been updated by the Application Service Steward '+ applicationServiceStewardName;
}