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

Hello @PRAKASH YADAV ,

 Please find the below comments:

But the same value is not populating in the RITM or Task for the Open source Variable --> The value should be updated on RITM or Task as well because the script I provided above will update the variable value directly on RITM record.

actually the Open Source variable itself is disappeared on RITM and Task after running the script --> Please check if there is any ui policy which is hiding the field value if it is set as "No"

Currently In the sc_item_option Table cat item or sc cat item option fields are empty against the variable Open source, Is this even good to populate the value of variable against the RITM? --> I don't see any issue if you have to update any variable on sc_req_item table via script you can do it.

Please mark my respsone as helpful/correct, if it answer your question.

Thanks