Can't create new record from workspace client script

e_wilber
Tera Guru

This UI action button appears in our workspace as expected but it's failing after t4 is alerted. I couldn't figure out where this was failing so I put in a bunch of alerts but everything t1-t4 shows up but t5 doesn't. The new record isn't being created.


This UI action is in global scope. What am I doing wrong to make this insert the new record from workspace?

 

function onClick(g_form) {
    alert('t1');
    var addRole = new GlideRecord('sys_user_has_role');
    alert('t2');
    addRole.role = '9b94fc24d7700200e5982cf65e610358'; // sn_customerservice.customer_admin
    alert('t3');
    addRole.user = g_form.getUniqueValue();
    alert('t4');
    var newRec = addRole.insert();
    alert('t5');
    g_form.save();
   
}
1 REPLY 1

Shivalika
Mega Sage

Hello @e_wilber 

 

Why are you passing g_form.getUniqueValue() in place of user ? I mean it's a client side script and you are using in server side - it wont work. 

 

Which form is it ? And what are you expecting by clicking the ui action ? 

 

Kindly mark my answer as helpful and accept solution if it helped you in anyway. This will help me be recognized for the efforts and also move this questions from unsolved to solved bucket. 

 

Regards,

 

Shivalika 

 

My LinkedIn - https://www.linkedin.com/in/shivalika-gupta-540346194

 

My youtube - https://youtube.com/playlist?list=PLsHuNzTdkE5Cn4PyS7HdV0Vg8JsfdgQlA&si=0WynLcOwNeEISQCY