- 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 09:51 PM
please share some screenshots.
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 10:33 PM
This is the UI Action :
2. The above UI Action is placed on knowledge article form:
3. When clicked on this UI action, it should open a dialog window with list of records from custom table:
4. Once the dialog window open, when I click on any record then dialog window should destroy and one reference field which is referenced to that custom table should get populated. For me that field is not getting populated.
Note: Basically we want this UI action to work similarly as how look up works for reference field. We cannot use look up function because this reference field will be hidden on form using UI Policy. In order to populate this Reference field we are using UI Action.
Thanks in advance
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
09-10-2023 10:50 PM
are you able to detect the click of any record somehow in that UI page? If yes then only you will be able to know which record was clicked?
Since the whole purpose is to select the reference record and I believe the reference field is also referring to same custom table why not show that field and allow user to select the record directly? anyhow you are showing the list of records similar to how lookup icon works
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 10:58 PM - edited 09-10-2023 11:00 PM
If you see my UI Action code - there I have placed two alerts in that = alert(msg) and alert(exName).
So , alert(msg) displays the name of the record which I clicked where as second alert(exName) returns undefined.
And we cannot display this reference field. According to client, it should remain hidden to customer. That's why we are going with UI Action approach. If we were allowed to show that reference our work would have become very easy but unfortunately we have to hide it.
Thanks in advance.