- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-08-2023 08:55 AM - edited 09-10-2023 05:02 AM
Hi Everyone,
I have created UI action knowledge article form. When I click on that UI Action then it should open dialog box with list of records from custom table. I click on any record then dialog box should destroy and there is reference field on knowledge article that should get populated. This reference field is not getting populated.
UI Action:
function openCustom() {
var table = "x_custom_table"; // Custom table name
var tableList = "x_custom_table_list"; //list of custom table
var dialog = new GlideDialogForm("Table", tableList);
dialog.setDialogHeight('800');
dialog.setDialogWidth('800');
dialog.setLoadCallback(populate);
dialog.render();
function populate(item) {
var fields = ["x_model_name"]; //x_model_name is a string field on custom table form
var msg = "";
fields.forEach(function(field) {
msg += item.getElementById(table + "." + field).value + "\n";
});
alert(msg);
var exName = g_form.setValue("x_ref_name", msg); // x_ref_name is reference field on kowledge article form.
alert(exName);
if (item.getElementById('sys_uniqueValue').value)
dialog.destroy();
}
}
Please guide me how can I populate reference field. All functionalities are working in my requirement except reference field getting populated.
cc: @Ankur Bawiskar @kamlesh kjmar
Thanks in advance
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 01:23 AM
yes either use GlideAjax or query directly.
But this will help only if you have unique record for that field value
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-10-2023 11:12 PM
alert(msg) shows sysId of selected record?
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-10-2023 11:24 PM
alert(msg) shows the name of that record - for example if you look into screenshot of dialog window there is field call Experience Name - that is coming in alert(msg). Unfortunately sys_id is not coming.
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2023 11:29 PM
you can query the table with that field and get the sysId but that field should be unique
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-10-2023 11:50 PM
Hi @Ankur Bawiskar,
If I try to make it clear, you are saying to do GlideAjax to script include. And there I can do GlideRecord and get sys_id.
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-11-2023 01:23 AM
yes either use GlideAjax or query directly.
But this will help only if you have unique record for that field value
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader