Create Case From RITM and map variable editor to description

neethu4
Giga Expert

Hi All,

I have created a Related Link to create case from RITM.But i want to map the variables(variable editor) which is on the RITM to the Case description fields.And this not for a specific catalog so i can't use current.variables.variable_name.For all RITM how can i map the variable( filled variables from form) to description field of the case?

Please let me know if anyone has idea on this

Thanks,

Neethu

1 ACCEPTED SOLUTION

gupta_vipul013
Mega Expert

Hi Neethu,



Please use the below to code to get the same:



var item = new GlideRecord("sc_req_item");  


item.get('0baad879dbbf3200a58c79daae961944');


var description;



// grab all variable sets from the parent request  


    var var_own = new GlideRecord('sc_item_option_mtom');  


    var_own.addQuery('request_item', item.sys_id);        


    //var_own.addQuery('sc_item_option.item_option_new.u_approval_display', 'global');  


    var_own.orderBy('sc_item_option.item_option_new.order');  


    var_own.query();          


       


    while (var_own.next()){  


              // store all the answers of each variable along with question.


description = description+var_own.sc_item_option.item_option_new.question_text + ": " + eval('item.variable_pool.'+var_own.sc_item_option.item_option_new.name+'.getDisplayValue()') + "\n"


      }


//Now you can use description variable



Please let me know, if you have any issues related to the code.



Regards,


Vipul


View solution in original post

3 REPLIES 3

gupta_vipul013
Mega Expert

Hi Neethu,



Please use the below to code to get the same:



var item = new GlideRecord("sc_req_item");  


item.get('0baad879dbbf3200a58c79daae961944');


var description;



// grab all variable sets from the parent request  


    var var_own = new GlideRecord('sc_item_option_mtom');  


    var_own.addQuery('request_item', item.sys_id);        


    //var_own.addQuery('sc_item_option.item_option_new.u_approval_display', 'global');  


    var_own.orderBy('sc_item_option.item_option_new.order');  


    var_own.query();          


       


    while (var_own.next()){  


              // store all the answers of each variable along with question.


description = description+var_own.sc_item_option.item_option_new.question_text + ": " + eval('item.variable_pool.'+var_own.sc_item_option.item_option_new.name+'.getDisplayValue()') + "\n"


      }


//Now you can use description variable



Please let me know, if you have any issues related to the code.



Regards,


Vipul


bubuprasadswain
Tera Guru

Hi Neethu,



You can write a background script to update for all Case description field from RITM.


var ritm = new GlideRecord('sc_req_item');


ritm.addQuery('active',true);


ritm.query();



while(ritm.next()){


      var desc = ritm.variables.description; // pass ritm variable description field


      var case = new GlideRecord('case_table'); // pass case table name here


              case.addQuery('ritm_number',ritm.number); // query the case record from which RITM it got created.


            case.query();


  if(case.next()){


          case.description = desc;


          case.update();


        }



}




Hope this helps.



Regards,


Bubuprasad


Hi Babuprasad,


This script is specific to description field but in my scenario whatever the variable on the RITM it should map to description field on the case form.


Thanks,


Neethu