Need to update the Field

Saib1
Tera Guru

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

 

find_real_file.png

1 ACCEPTED SOLUTION

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.

View solution in original post

9 REPLIES 9

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();
   }
}


Thanks Raghu

I am planning to update on the cmdb_ci_server table.

under this table we have so many classes. All these classes have different table name . 

Is that will also get updated if i update on the cmdb_ci_server table.

 

find_real_file.png

Ohh, Got it.. 

Then you need to run the code on each class. I Hope there wont be many..

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

find_real_file.png

 

find_real_file.png

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.