g modal reference field

eyal abu hamad
Mega Sage

Hello, I created a UI action that create new contact.
I used g modal for pop up and I'm trying to add refence filed but with no luck showing values.
the UI action is in global and I tried also in customer service app.

eyalabuhamad_0-1707309029622.png

eyalabuhamad_1-1707309048345.png

as you can see that the reference filed is created but with no values.
what the problem could be ?

2 ACCEPTED SOLUTIONS

Harsh Vardhan
Giga Patron

@eyal abu hamad  Change the name attribute value.

 

From

 name: 'customer account',

 

to 

 

 name: 'account',

 

Give a try, I think it should work after this.

 

Thanks,

Harsh

View solution in original post

Hi, 

Please check the name you are giving 'customer account' ..

It may be 'customer_account' ..please check once

If type is reference: 

then name should be the  reference field on the current record being used to search

 

View solution in original post

11 REPLIES 11

Sarika S Nair1
Kilo Sage

Hi , 

Use g:ui_reference in your UI page for creating reference field 

example: 

<g:ui_reference name="account" id="account_id"  
table="<account table name>"  
query="active=true"  
columns="account_id,account_name"/> 

 

I'm not using UI page. it is UI action

eyalabuhamad_0-1707309721237.png

 

Hi, 

Are you not passing any UI page in GlideModal?

Like below 

var gModal = new GlideModal('ui_page_name');

 

can you share the code you are using in your UI Action

 function onClick(g_form) {


     g_modal.showFields({
         title: "New Caller",
         fields: [{
             type: 'textarea',
             name: 'first name',
             label: getMessage('first name'),
             mandatory: true
         }, {
             type: 'textarea',
             name: 'last name',
             label: getMessage('last name'),
             mandatory: true
         }, {
             type: 'choice',
             name: 'line of bussiness',
             label: getMessage('line of bussiness'),
             value: getMessage(' -- Select -- '),
             choices: [{
                     displayValue: 'Retail',
                     value: 'retail'
                 },
                 {
                     displayValue: 'Unattended',
                     value: 'unattended'
                 }
             ],
             mandatory: true
         }, {
             type: 'reference',
             name: 'customer account',
             label: getMessage('Account'),
             mandatory: false,
             reference: 'customer_account',
             referringTable: 'sn_customerservice_case',
             referringRecordId: g_form.getUniqueValue()
         }, {
             type: 'textarea',
             name: 'email',
             label: getMessage('Email'),
             mandatory: true
         }],
         size: 'lg'
     }).then(function(fieldValues) {
         var ga = new GlideAjax('global.CSManagementUtils');
         ga.addParam('sysparm_name', 'createNewContact');
         ga.addParam('sysparm_firstName', fieldValues.updatedFields[0].value);
         ga.addParam('sysparm_lastName', fieldValues.updatedFields[1].value);
         ga.addParam('sysparm_lob', fieldValues.updatedFields[2].value);
         ga.addParam('sysparm_account', fieldValues.updatedFields[3].value);
         ga.addParam('sysparm_email', fieldValues.updatedFields[4].value);

         ga.getXML(updateCampus);

         function updateCampus(response) {

             var answer = response.responseXML.documentElement.getAttribute("answer");
             
             if (answer) {
                 var mandField = g_form.getFieldNames();
                 var onlyMnad = mandField.filter(filterForMissingMandatoryFields);
                 for (var i = 0; i < onlyMnad.length; i++) {
                     g_form.setMandatory(onlyMnad[i], false);
                 }
				g_form.getValue('u_caller',answer);
                 //g_form.u_caller = answer;
                 //g_form.save();
             }
         }
     });
 }

 function filterForMissingMandatoryFields(field) {
     //check if field is mandatory
     if (g_form.isMandatory(field)) {
         //return if there is no value
         return !g_form.getValue(field);
     }
 }