
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2021 08:08 AM
Hello,
I've created an UI Action for Agent Workspace which gives me some kind of result.
function onClick( g_form ) {
g_modal.showFields({
title: "Reference Field Test",
fields: [{
type: 'reference',
name: 'caller_id',
label: 'Label 0',
referringTable: 'incident',
referringRecordId: g_form.getUniqueValue(),
}],
size: 'lg'
});
}
I do however want to reference my own table that I've created but I can't seem to get it to work. Here's what I've tried:
function onClick( g_form ) {
g_modal.showFields({
title: "Reference Field Test",
fields: [{
type: 'reference',
name: 'u_name',
label: 'Label 1',
referringTable: 'sn_agent_workspace_external_users',
referringRecordId: g_form.getUniqueValue(),
}],
size: 'lg'
});
}
I was unable to find any documentation on this so that's why I'm asking a question here. Has anyone done something similar before that could point me in the right direction?
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2021 08:19 AM
Hi
This is a sample for the incident, try this as per your requirement.
function onClick(g_form) {
var fields = [{
type: 'reference',
name: 'caller_id', //Give your custom reference field
label: getMessage('What is your name?'), //Give as per your requirement
mandatory: true,
reference: 'sys_user', //Give which table your custom field refers to
referringTable: 'incident', //Give your custom table
referringRecordId: g_form.getUniqueValue()
}
];
g_modal.showFields({
title: "Enter your details",
fields: fields,
size: 'lg'
}).then(function(fieldValues) {
g_form.setValue('caller_id', fieldValues.updatedFields[2].value);
g_form.save();
});
}
For more Info Workspace UI ACtions
Please mark my answer as helpful/correct, if applicable.
Best regards,
Sai Kumar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2021 08:19 AM
Hi
This is a sample for the incident, try this as per your requirement.
function onClick(g_form) {
var fields = [{
type: 'reference',
name: 'caller_id', //Give your custom reference field
label: getMessage('What is your name?'), //Give as per your requirement
mandatory: true,
reference: 'sys_user', //Give which table your custom field refers to
referringTable: 'incident', //Give your custom table
referringRecordId: g_form.getUniqueValue()
}
];
g_modal.showFields({
title: "Enter your details",
fields: fields,
size: 'lg'
}).then(function(fieldValues) {
g_form.setValue('caller_id', fieldValues.updatedFields[2].value);
g_form.save();
});
}
For more Info Workspace UI ACtions
Please mark my answer as helpful/correct, if applicable.
Best regards,
Sai Kumar

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2021 09:05 AM
Hello and thank you for your response.
My UI Action is in the Interaction view in Agent Workspace which doesn't have the reference field in it. I was hoping that I could just create a reference field within g_modal. Maybe that's not supposed to work?
I did just try this down below. The u_name is the name of the field in the custom table which is not present in the current Interaction.
function onClick( g_form ) {
g_modal.showFields({
title: "Reference Field Test",
fields: [{
type: 'reference',
name: 'u_name', //Give your custom reference field
label: getMessage('What is your name?'),
mandatory: true,
reference: 'sn_agent_workspace_external_users'
referringTable: 'sn_agent_workspace_external_users',// I've tried with Interaction here as well without success
referringRecordId: g_form.getUniqueValue()
}],
size: 'lg'
});
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-19-2021 09:15 AM
Hello again.
I managed to solve it by adding the actual reference field to the Interaction table. I didn't think I would have to. I'll just hide it with an UI policy..
Thank you for your help!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-22-2021 06:56 PM
An alternative way to trick the modal into allowing you to include a Reference field that DOESN'T exist on the g_form object would be to find another record that already references your custom table, for example for the following tables:
my_custom_table
my_custom_table_child
Where there is a field called my_custom_table_child.u_custom_parent which references my_custom_table you could do this:
function onClick( g_form ) {
g_modal.showFields({
title: "Reference Field Test",
fields: [{
type: 'reference',
name: 'u_custom_parent', // this field exists on my referring table but NOT on my g_form table.
label: getMessage('What is your name?'),
mandatory: true,
reference: 'my_custom_table',
referringTable: 'my_custom_table_child',// Note that the referring table can be completely different to the g_form table
referringRecordId: '-1' // setting this to -1 tricks SN into thinking this is a brand new record
}],
size: 'lg'
});
}
This has worked for me, but I'm finding that I always inherit the reference qualifier of the referring table's reference and I can't override it with query: '<encoded query string>' which is causing me some problems.