How to export the variables of specific RITMs in XML?

Suggy
Giga Sage

We have around 3000 RITMs but I need to move only 500 RITMs from one SN to another SN instance (including the variables and its values for 500 RITMs)

 

I used a filter to export those 500 RITM via XML and imported in target instance but the variables section did not show up on the RITM, and I understand the reason - that the variable data sits in different table which is sc_item_option.

 

Hence, I went to sc_item_option table to export the XMLs but problem is that, I couldnt find a way to use the filter on this table.. something like 'RITM is one of <1,2,3..500>' on this table.

 

Anyone knows how to export the variables and its values from sc_item_option table for those specific 500 RITMs?

1 ACCEPTED SOLUTION

Hi @Suggy ,

 

yes run the script in the source instance 

you will get the sysids of the those variable and value records

 

goto those tables and filter the records using sysid is one of {out put sysids}

 

and then export them as xmls

 

ChaitanyaILCR_0-1752758471027.png

 

ChaitanyaILCR_2-1752758695991.png

 

do the same with sc_item_option_mtom

 

ChaitanyaILCR_3-1752758726420.png

 

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

View solution in original post

17 REPLIES 17

Hello @Suggy , 

 

If you have list of RITM numbers then you can add the filter on the sc_item_option_mtom.LIST table as Parent.number is one of <RITM_numbers>.


 

If my response was helpful, please mark it as correct and helpful.
Thank you.

Chaitanya ILCR
Mega Patron

HI @Suggy ,

Run this in the background script 

 

add the encoded query with you encoded query in the 5th line to filter the 500 ritms (i have added active=true as a place holder replace it with yours)

 

i have added 4 gs.info statements

1st prints (sc_item_option)

2. prints sysids related to that table

 

3. prints (sc_item_option_mtom)

4. prints sysids related to that table

 

it will print sysids into the console

copy the sysids and go to respective tables and filter the list using sysid and export those records as xmls

var scItemOptionIDs = []
var scItemOptionMTOMIDs = []

var ritmGr = new GlideRecord('sc_req_item');
ritmGr.addEncodedQuery('active=true');//add your encoded query to filter those 500 ritms
ritmGr.query();
while (ritmGr.next()) {
    var scItemMtomGr = new GlideRecord('sc_item_option_mtom');
    scItemMtomGr.addQuery('request_item', ritmGr.getValue('sys_id'));
    scItemMtomGr.query()
    while (scItemMtomGr.next()) {
        scItemOptionMTOMIDs.push(scItemMtomGr.getValue('sys_id'));
		scItemOptionIDs.push(scItemMtomGr.getValue('sc_item_option'))
    }
}

gs.info('sc_item_option')

gs.info(scItemOptionIDs)

gs.info('sc_item_option_mtom')


gs.info(scItemOptionMTOMIDs)

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

@Chaitanya ILCR  I dont want the output. I want the XML for variables and its values for those 500 RITMs 

Hi @Suggy ,

 

yes run the script in the source instance 

you will get the sysids of the those variable and value records

 

goto those tables and filter the records using sysid is one of {out put sysids}

 

and then export them as xmls

 

ChaitanyaILCR_0-1752758471027.png

 

ChaitanyaILCR_2-1752758695991.png

 

do the same with sc_item_option_mtom

 

ChaitanyaILCR_3-1752758726420.png

 

 

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

Hi @Suggy ,

 

Have you had a chance review my response?

if this make sense to you. could you please mark the response as helpful and accept it as a solution and close the thread

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya