- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2023 05:21 AM
Hi Team,
I want to insert all the selected records from list collector to mrvs, but it's inserting only one in mrvs(for ex if i select 5 records also it's inserting only one record in mrvs)
Please find below script
Script Include
Thanks,
Preethi
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-03-2023 05:33 AM
I hope you are using correct variable names in script include while forming the object
update as this
var assetdetails = Class.create();
assetdetails.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getAssetDetails: function(){
var asset = this.getParameter('sysparm_asset');
var arr = [];
var gr = new GlideRecord('alm_hardware');
gr.addQuery('sys_id', 'IN' ,asset);
gr.query();
while(gr.next())
{
var obj = {};
obj["v_asset_tag"] = gr.getValue("asset_tag");
obj["v_serial_number123"] = gr.getValue("serial_number");
arr.push(obj);
}
return JSON.stringify(arr);
},
type: 'assetdetails'
});
Client script:
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var list = g_form.getValue('v_serial_number').toString();
var ga = new GlideAjax('global.assetdetails');
ga.addParam('sysparm_name', 'getAssetDetails');
ga.addParam('sysparm_asset', list);
ga.getXML(result);
a
function result(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
g_form.setValue('asset_addition', answer);
}
}
If my response helped please mark it correct and close the thread so that it benefits future readers.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-22-2023 12:25 AM
then add that logic in script include itself and only send those sysIds which satisfy the date
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2023 12:52 AM
Need help on this
In below script i want to display alert message as arr1 and another arr values i want to add in mrvs.But with my script is displaying arr as a alert message.
I want both arr in client script.
Script include
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-23-2023 02:49 AM
You already have another thread for the new question.
Please add script in that post and tag me.
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader