- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2022 10:44 AM
Hi ,
I need to update the Used For field value to Environment field . This should be in cmdb_ci_server table.
On this table we have different classes . All the classes should also get updated in Environment , when Used For field is Inserted or Updated.
How to implement this
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 05:09 AM
Hi,
Do like below...
In Filter condition modify like below
used for changes
or
environment changes
In script change like below
if(current.used_for.changes())
{
current.environment = current.used_for;
}
if(current.environment.changes())
{
current.used_for = current.environment;
}
I hope it will be helpful, if so please mark my answer as correct and helpful.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2022 10:40 PM
Ok, then use schedule job or background script to update it, use code something like below.
var gr = new GlideRecord('table_name');
gr.query();
while (gr.next()) {
if (gr.usedby_variablename!=''){
gr.environment_variablename = gr.usedby_variablename
gr.update();
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2022 10:43 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-02-2022 11:14 PM
Ohh, Got it..
Then you need to run the code on each class. I Hope there wont be many..
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 04:41 AM
Hi Raghu,
On the Business Rule , when they are changing the field Used For , Environment will get updated .
Vice Versa i neeed to updated when Environment field is updated Used For field also get updated.
can you tell what condition we need to give in "when to run" and Advance tab what code should be written
As of now i have only one condition . but need 2 condition should work
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-03-2022 05:09 AM
Hi,
Do like below...
In Filter condition modify like below
used for changes
or
environment changes
In script change like below
if(current.used_for.changes())
{
current.environment = current.used_for;
}
if(current.environment.changes())
{
current.used_for = current.environment;
}
I hope it will be helpful, if so please mark my answer as correct and helpful.