How to update a Variable Value in many Catalog Tasks using Fix Script.

Community Alums
Not applicable

How to update a Variable Value in the Catalog Tasks using Fix Script.

Details :

I have a Variable "open source" and its type is select box , it has values { None, Yes, No} and its on one of the catalog Item , the catalog item is used to retire a business apllications 

Now I have more Tasks for retiring a business apllications and now on all these tasks the Variable "open source" should be updated with value "No"

 

1 ACCEPTED SOLUTION

AnirudhKumar
Mega Sage
Mega Sage

Here's the Fix script you need:

var fieldObj = new GlideRecord("sc_item_option");
fieldObj.addQuery("item_option_new", '<<variable sys id from catalog item>>');
fieldObj.query();
while (fieldObj.next()) {
    fieldObj.value = 'Yes'; //Use right backend name
    fieldObj.update();
}

 

Warning : Be careful with fix scripts, if possible run it for 1 RITM and verify the results.

View solution in original post

10 REPLIES 10

AnirudhKumar
Mega Sage
Mega Sage

Here's the Fix script you need:

var fieldObj = new GlideRecord("sc_item_option");
fieldObj.addQuery("item_option_new", '<<variable sys id from catalog item>>');
fieldObj.query();
while (fieldObj.next()) {
    fieldObj.value = 'Yes'; //Use right backend name
    fieldObj.update();
}

 

Warning : Be careful with fix scripts, if possible run it for 1 RITM and verify the results.

Community Alums
Not applicable

Hi Anirudh,

It did not work.

I have 70 Tasks created  in the sc_task Table , the Tasks are created for the catalog item "Retire business application" and it has the Variable Open_source

Now I should update Variable open_source=No on all those 70 Tasks , hope this gives some good understanding on the Requirement .

Please help with it.

I hope you are using the right sysid in the query. ( it needs to be the sysid of the variable open_source).

Also, try 

fieldObj.value = 'no'; //Use right backend name

It should update the field on the RITM's variable editor and also on the task's variable editor

Community Alums
Not applicable

Anirudh,

How can i test it for only 1 Request Item,

lets say my RITM is RITM4596087096 and sys id is aadsdf89465905lfmglh

and in the Table sc_item_option , I could see only cart item,  I dont find the cat item or sc cat item option against the variable Open source

fieldObj.value = 'no'; //Use right backend name

Here right backend name is the backend name of Variable Right?

I have doubt , no where in the above code we are querying the RITM or Task but how could our code update the variable value against each RITM