kartiksethi
Tera Guru

Hi @Juan 

 

Please check the code provided below:

getRitmByCitem('<your_citem_sys_id_goes_here>');


function getRitmByCitem(citemID) {
    var ritmGr = new GlideRecord('sc_req_item');
    ritmGr.addQuery('cat_item', citemID);
    ritmGr.query();
    //For Testing comment WHILE loop and uncomment IF loop
    while(ritmGr.next()) {
    //if(ritmGr.next()) {
        gs.print(getVariableResponse(ritmGr));
    }
}

function getVariableResponse(ritmGr) {
    var scOptionGr = new GlideRecord('sc_item_option_mtom');
    scOptionGr.addEncodedQuery('request_item=' + ritmGr.getValue('sys_id'));
    scOptionGr.query();
    while(scOptionGr.next()) {
        return 'Parent Item: ' + ritmGr.number + '\tQuestion: ' + scOptionGr.sc_item_option.item_option_new.getDisplayValue() + '\tQuestion Sys ID: ' + scOptionGr.sc_item_option.item_option_new + '\tValue: ' + scOptionGr.sc_item_option.value;
    }
}

Please check and let me know if this helps!


Please mark my answer as correct if this solves your issues!

If it helped you in any way then please mark helpful!

 

Thanks and regards,

Kartik