g_modal - Create a reference field

Jonas Svensson
Tera Expert

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?

1 ACCEPTED SOLUTION

Sai Kumar B
Mega Sage
Mega Sage

Hi @jsfour 

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

View solution in original post

5 REPLIES 5

Hi @Sai Kumar B ,

Incase you know how to display Date/Time field using g_modal.showFields, please let us know.