- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2023 01:33 AM
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:
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-26-2023 07:32 AM
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;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2023 01:46 AM
Hi @matthew_hughes ,
getValue will return the sys_id of the reference field, to get the display name of the user, use getDisplayValue, please try with the code below:
(function executeRule(current, previous /*null when async*/) {
var businessApplicationSteward = current.u_cmdb_data_steward.getDisplayValue();
var technicalApplicationOwner = current.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);
If my answer has helped with your question, please mark it as correct and helpful
Thanks!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2023 01:58 AM
I tried that but it didn't work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2023 02:05 AM - edited 05-24-2023 02:09 AM
On above script, work note line should be like below as .name is not required(won't work) as you already have display value in businessApplicationSteward
current.work_notes = 'The Business Applicaion Type field has been updated by the Business Application Steward '+ businessApplicationSteward;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-24-2023 02:10 AM
Can you please try below:
(function executeRule(current, previous /*null when async*/) {
var businessApplicationSteward = current.u_cmdb_data_steward ;
var technicalApplicationOwner = current.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 '+
(current.u_cmdb_data_steward).getDisplayValue();
}
})(current, previous);
I hope "businessApplicationSteward " stores the sys_id of some user right
If my answer solved your issue, please mark my answer as ✅Correct & 👍Helpful based on the Impact.