Can we Make users to select the choice field (State Field ) in POP up message?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2022 09:13 PM
My Requirement is To show a POP up message with the State choice Field, From that the user should choose the State fields by UI action through Testing Buttons.
On clicking the Testing Button, POP up Message should get displayed with State field , from that the user should select the choice, but other choices are not getting displayed , how tosolve this?
function onClick(g_form) {
g_modal.showFields({
title: "Enter your reason",
fields: [{
type: 'reference',
name: 'state',
label: getMessage('Reason'),
mandatory: true,
reference:'state',
referringTable: 'incident',
referringRecordId: g_form.getUniqueValue(),
value: g_form.getValue('state'),
displayValue: g_form.getDisplayValue('state'),
}],
size: 'lg'
}).then(function(fieldValues) {
g_form.setValue('state', fieldValues.updatedFields[0].value);
g_form.save();
});
}
what to change in script?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2022 10:04 PM
Hi,
your type is reference then how it will show choices
you should be using type as choice
Refer my blog and enhance the logic
Populating dynamic choices in workspace form pane for choice field type
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2022 10:08 PM
your script will look like this
Enhance as per your requirement
function onClick(g_form) {
var arr = [];
var obj = {};
obj["value"] = "1";
obj["displayValue"] = "New";
arr.push(obj);
var obj1 = {};
obj1["value"] = "2";
obj1["displayValue"] = "Work in progress";
arr.push(obj1);
g_modal.showFields({
title: "Enter your reason",
fields: [{
type: 'choice',
name: 'state',
label: getMessage('Reason'),
mandatory: true,
choices: arr
}],
size: 'lg'
}).then(function(fieldValues) {
g_form.setValue('state', fieldValues.updatedFields[0].value);
g_form.save();
});
}
Regards
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-07-2022 10:56 PM
yes bro its working. But , i need When user is Selecting New , automatically another task should be created how to do this?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-08-2022 07:55 PM
Is it possible to create a task from this pop up itself, then from where i need to change the script, can you please provide me with script