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

Community Alums
Not applicable

Hi Anirudh,

Could you please respond on it.

Thanks and Regards,

Prakash Yadav.

@PRAKASH YADAV 

Here's what happens when you submit your catalog item... 

Depending on the number of fields in your catalog item, records gets created in the Variable Ownerships table (sc_item_option_mtom). The Parent Item remains same (RITM value) for all these records, but the Dependent Item fields carry different values (details about the values filled on the catalog form).

 

The Dependent Item field is a reference to sc_item_option, the table we gliderecord in our script. On an sc_item_option form, the 2 main fields are Value and Question. Question stores the variable sysid and Value stores the values entered on the catalog form.

 

Note that these values are carried over to the variable editors on the RITM and catalog task. Any change made on the Value field on these records will be reflected on the RITM and Catalog task variable editors.

 

In the script I shared earlier, we are simply accessing all those records that have stored the open_source field values and updating them to 'no'. 

Community Alums
Not applicable

Hi Anirudh,

Yes, the script is working good and it updating the value No on sc_item_option form for the variable Open source 

But the same value is not populating in the RITM or Task for the Open source Variable , actually the Open Source variable itself is disappeared on RITM and Task.

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?

 

Is there way a to query  sc_item_variables_task Table and update the variable ?

Thanks and Regards,

Prakash Yadav.

 

Mahendra RC
Mega Sage

Hello @PRAKASH YADAV ,

Please check with below script:

var fieldObj = new GlideRecord("sc_req_item");
fieldObj.addQuery("number", 'RITM0010529');
fieldObj.query();
while (fieldObj.next()) {
    fieldObj.variables.<variable_name> = "No"; //Use right backend name
    fieldObj.update();
}

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

Thanks

Community Alums
Not applicable

Hi Mahendra,

Yes, the script is working good and it updating the value "No" on sc_item_option form for the variable Open source 

But the same value is not populating in the RITM or Task for the Open source Variable , actually the Open Source variable itself is disappeared on RITM and Task after running the script.

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?

Actually  the open source variable is Non Editable on the RITM form.

Thanks and Regards,

Prakash Yadav.