Setting a field mandatory in Onload client script

samadam
Kilo Sage

I have a n onload client script where I am checking the state and setting a field mandatory but it is not working. There are no UI policies on this field. I dont even get the alert in the beginning of the script I added.

var st = g_form.getValue('u_state');
    alert(st);
  if (st == 'Draft'){
        g_form.setMandatory('u_ship', true);
  }
1 ACCEPTED SOLUTION

Jim Coyne
Kilo Patron

Check the console in your browser's developer tools.  I'm guessing there's an error somewhere else that's stopping this script from running.

 

Once you figure that out, it's probably a good idea to switch over to a UI Policy to set it mandatory.

View solution in original post

6 REPLIES 6

Sandeep Rajput
Tera Patron
Tera Patron

@samadam Please check the following points on your onLoad script.

1. Please check if the Active checkbox on the client script form is checked.

2. Please check if the UI Type is set to All

3. Please check if the global checkbox on your client script is checked.

 

Hope this helps.

Jim Coyne
Kilo Patron

Check the console in your browser's developer tools.  I'm guessing there's an error somewhere else that's stopping this script from running.

 

Once you figure that out, it's probably a good idea to switch over to a UI Policy to set it mandatory.

Jim Coyne
Kilo Patron

@Sandeep Rajput has some good points there.

 

If there are no errors, are you sure the script is setup properly?  Where is it expected to run?  Fulfiller UI, Workspace, Portal?

samadam
Kilo Sage

I am checking the console, but all rest are set. It is supposed to run in native UI. I need this field mandatory once the state is set not on change i.e user manually moving state to Draft.