- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2018 04:30 AM
I have a few custom fields on the Release Table (rm_release). 2 of this fields are for string values of List fields, the fields will be hidden and are only there for reporting purposes.
Our workflow is as such create new Release(parent), > Create Release (child) > Create Task
This tab is visible on Child releases and what I would like to do is copy the string value from Environments Used to Env Used and Environments Not Used to Env Not Used.
The values in Environments Used & Not Used are populated only when a new task has been created and the Application Environment selected (which is a reference field to the CMDB_CI table).
I have run the below code as a background script and it worked as expected
(function executeRule(current, previous /*null when async*/) {
var env = new GlideRecord ('rm_release');
env.query();
while (env.next()){
env.u_env_used_string = env.getDisplayValue('u_environments_used')
env.setWorkflow(false);
env.update();
}
})(current, previous);
But I am struggling to get it to work as a Business Rule, I've tried before and after, but I think the issue is that the fields I'm trying to copy from are populated when the task is created so there is no Insert or Update of the record. I have tried to update the record, adding work notes for example and still the fields are not populated.
Can anyone assist as to how to get the above code to run as release records are created or updated on an adhoc basis. If not I'm guessing I could always run it as a scheduled Script execution.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2018 04:42 AM
You can try with OnAfter BR - Insert
(function executeRule(current, previous /*null when async*/) {
var env = new GlideRecord ('rm_release');
env.query();
while (env.next()){
env.u_env_used_string = env.u_environments_used.getDisplayValue();
env.setWorkflow(false);
env.update();
}
})(current, previous);
Thanks
Shashikant
Hit Helpful or Correct on the impact of response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2018 04:42 AM
You can try with OnAfter BR - Insert
(function executeRule(current, previous /*null when async*/) {
var env = new GlideRecord ('rm_release');
env.query();
while (env.next()){
env.u_env_used_string = env.u_environments_used.getDisplayValue();
env.setWorkflow(false);
env.update();
}
})(current, previous);
Thanks
Shashikant
Hit Helpful or Correct on the impact of response.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-27-2018 05:37 AM
Hi Shashikant,
Thanks for your assistance, I tried it as an OnAfter BR with the small code change you suggested and it is now populating the field.