Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-17-2022 05:52 AM
Hi,
if you wish to add None then do this
Script Include:
var arr = [];
// to add None
arr.push({
"value":"",
"displayValue":"-- None --"
});
var DWN = new GlideRecord("u_customer");
DWN.addQuery("u_active", true);
DWN.addQuery("u_name", "Customer Specific Type");
DWN.addQuery('u_customer',' b70c0f830f37330013a831ef68767e33');
DWN.query();
if (DWN.next()) {
PARMS = DWN.u_parms.split(',');
gs.info("PARMS " + PARMS.length + "--" + PARMS);
for (var i = 0; i < PARMS.length; i++) {
var obj = {};
var choice = new GlideRecord('sys_choice');
choice.addQuery('name', 'incident');
choice.addQuery('language', 'en');
choice.addQuery('element', 'contact_type');
choice.addQuery('inactive', false);
choice.addQuery('value', PARMS[i]);
choice.query();
if (choice.next()) {
obj["value"] = choice.value.toString();
obj["displayValue"] = choice.label.toString();
arr.push(obj);
}
}
}
var result = {};
result["choices"] = arr;
return JSON.stringify(result);
},
Workspace client script:
function onClick(g_form) {
var fields = [];
fields.push({
type: 'string',
label: getMessage('Invoicer'),
value: g_form.getDisplayValue('consumer'),
readonly: true,
});
var ga = new GlideAjax('CDAInvoiceProcessor');
ga.addParam('sysparm_name', 'getInvoiceTypes');
ga.getXML(populateChoiceeField);
ga.getXMLAnswer(populateChoiceeField);
function populateChoiceeField(response) {
var msg = response;
var answer = JSON.parse(msg);
fields.push({
type: 'choice',
name: 'invoice_type',
label: getMessage('invoice type'),
choices: answer.choices,
mandatory: true
});
g_modal.showFields({
title: "Product for Invoice",
fields: fields,
size: 'lg'
}).then(function(fieldValues) {
g_form.setValue('short_description', fieldValues.updatedFields[1].value);
//<--------------------------------------------------------------------------------------->//
//<---------------------------------------------------------------------------------------->//
});
}
}
Regards
Ankur
Regards,
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader
Ankur
✨ Certified Technical Architect || ✨ 10x ServiceNow MVP || ✨ ServiceNow Community Leader