How can we get the xml of request item raised along with the variable values filled in for that request item, currently show xml shows only the fields not the variables

steffy1
Tera Contributor

How can we get the xml of request item raised along with the variable values filled in for that request item, currently show xml shows only the fields not the variables

7 REPLIES 7

My method described above can get you that data. You would need to include the appropriate tables in your processor script similar to the examples I shared.



-Jon


Sent from my iPhone


here is a processor I wrote to handle this.   let me know if this works.



var sysid = g_request.getParameter('sysparm_sys_id');


gs.log('** Exporting Requested Item ' + sysid);




// name all the related lists


var exporter = new ExportWithRelatedLists('sc_request', sysid);


exporter.addRelatedList('sc_req_item', 'request');


exporter.addRelatedList('sc_item_option_mtom', 'request_item.request');


exporter.addRelatedList('sc_task', 'request_item.request');


//approvals for the request record


exporter.addQuerySet('sysapproval_approver', 'sysapproval=' + sysid);


exporter.addQuerySet('sysapproval_group', 'parent=' + sysid);




//get option IDS so   we can get options from sc_item_option for each item


var optionIds = [];


var allOptions = new GlideRecord('sc_item_option_mtom');


allOptions.addQuery('request_item.request', sysid);


allOptions.query();


while (allOptions.next()) {


      optionIds.push(allOptions.getValue('sc_item_option'));


}


if (optionIds.length > 0){


    exporter.addQuerySet('sc_item_option', 'sys_idIN' + optionIds.join(','));


}




//get catalog IDs so   we can get options from item_option_new for each item


var catIds = [];


var reqIds = [];


var allReqs = new GlideRecord('sc_req_item');


allReqs.addQuery('request',sysid);


allReqs.query();


while (allReqs.next()) {


      catIds.push(allReqs.getValue('cat_item'));


  reqIds.push(allReqs.getValue('sys_id'));


}


if (catIds.length > 0){


    exporter.addQuerySet('item_option_new', 'cat_itemIN' + catIds.join(','));


}


if (reqIds.length > 0){


    exporter.addQuerySet('sysapproval_approver', 'sysapprovalIN' + reqIds.join(','));


  exporter.addQuerySet('sysapproval_group', 'parentIN' + reqIds.join(','));


}




exporter.exportRecords(g_response);


steffy1
Tera Contributor

Is there any way to achieve via request item workflow.