SetValue using sys_id

marskh1111
Kilo Contributor

My client needs the assigned to field to be mandatory for certain users. The issue I am having is the client also needs to assignment group to not show in this same situation. We have the assigned to field as a reference to the assignment group. I tried using the following script in a client script and it is not functioning as I thought it would. The assignment group is showing up false and the assigned to field no longer as the correct options under it.

Here is my script:

function onLoad() {

  if (g_user.hasRole('test_user) && !g_user.hasRole('admin_user)){

  g_form.setMandatory('assignment_group', false);

  g_form.setDisplay('assignment_group', false);

      g_form.setValue('assignment_group', '(sys id here', 'display value here');

        g_form.setMandatory('assigned_to);

  }else{

  g_form.setDisplay('assignment_group', true);

  }

}

7 REPLIES 7

Abhinay Erra
Giga Sage

Try this, there was a syntax error on the highlighted line


function onLoad() {


  if (g_user.hasRole('test_user) && !g_user.hasRole('admin_user)){


  g_form.setMandatory('assignment_group', false);


  g_form.setDisplay('assignment_group', false);


      g_form.setValue('assignment_group', '(sys id here', 'display value here');


      g_form.setMandatory('assigned_to', true);


  }else{


  g_form.setDisplay('assignment_group', true);


  }


}


Oops let me try that. Bigger issue is really that the assignment group isn't mapping right. I end up with no options to choose from in the assigned to field.



Sent from my iPhone


Try


g_form.setValue('assignment_group', 'sys id here'); and let me know if this works.


Do you have any reference qualifiers on assigned_to field?