Query in Ui action

servicenow lath
Tera Contributor

In My case table Whenever a Account is selected , that particualr account Primary_contact should seen in contact field in case form. 

if for particular account there is no contact means a button(create Contact) should enable in case form , and on clicking that button it should be able to go to create contact for that particular account and it should link to that particular case form also , i have created a BR and Ui action for that, but Ui action is not working , suggest me the error in the script

 

5 REPLIES 5

RaghavSh
Kilo Patron

You are trying to Glide in the client side of UI action.

I dont see a need to make this UI action "client". Just remove the getContact function and uncheck the client checkboc and directly glide and do the operation.

Anything written outside the function in UI action acts as server side so you can get the values from form using current. You dont need to use g_form class.


Please mark the answer correct/helpful accordingly.


Raghav
MVP 2023

made the changes

I am just converting your client side to server side , hope this helps:

var gr = new GlideRecord('customer_contact');
gr.addquery('name',current.account);
gr.query();
if(gr.next())
{
gr.initialize();
gr.insert();
}

Raghav
MVP 2023

But my issue is i need to display it in csm workspace . 

then how can i give this condition ?

!current.isNewRecord()&&current.contact==''