- 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-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-20-2023 11:21 PM
When I am adding 50 values from list collector, I have a retired date field if the assets are past date to current date then I need to display alert message like if 10 not not added in 50 then I need to show them in alert message
Thanks,
Preethi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-21-2023 09:09 PM
can you raise a new thread for this?
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:22 AM
While adding records from list collector to MRVS, I need to check retired date with current date and remove the past date records while adding to MRVS.
Thanks,
Preethi