Depending on the field, another field is Mandatory and Visible.

karishma shaik
Tera Contributor

Hi Team,

I need to get some code as per the requirement,

1) I had a choice field in custom table which had 3 choices in the choice field X,Y,Z. so when ever I select X or Y from the "Choice Field" then the "Text Field" should be appeared and when ever I select Z from the "Choice Field" then the "Text Field" should be disappeared.

2) I had a reference field with auto updated user and when we impersonate with that user, the "Text Field" should be mandatory also there will be a check box field and if the "Check Box" field is checked then the "Text Field" should be disappeared until the ticket is closed.

Please help me on this .

Thanks,

Karishma.

14 REPLIES 14

Hi Karishma,

You can do the same stuff using UI Policy in stead of complicating using client script. Try it. Because in client script you have to check all the aspects like whats happening when the form loads or gets updated.

Thanks,

Satanik

Yousaf
Giga Sage

Hi Karishma.

Please try this.

In System UI > UI Policies create a record and save it than on certain condition make any field Mandatory, Read Oly or Visible

find_real_file.png


***Mark Correct or Helpful if it helps.***

Hi Yousaf,

I have written the on-change client script, but there is no luck.

function onChange(control, oldValue, newValue, isLoading, isTemplate) {

  
    var payment = g_form.getValue('u_payment_method_verified');
    if (isLoading) {

        if ((pm == 'u_ach' || pm == 'u_wired') && (g_form.getValue('u_cost_accountant') == g_user.userID )) {

            g_form.setVisible('u_if_not_why', true);
            g_form.setMandatory('u_if_not_why', true);

     } else {

           g_form.setMandatory('u_if_not_why', false);
           g_form.setVisible('u_if_not_why', false);

       }
    } else {
        if ((pm == 'u_ach' || pm == 'u_wired') && (g_form.getValue('u_cost_accountant') == g_user.userID )) {
            g_form.setVisible('u_if_not_why', true);
            g_form.setMandatory('u_if_not_why', true);


        } else {
            g_form.setMandatory('u_if_not_why', false);
            g_form.setVisible('u_if_not_why', false);

        }
    }
    }

Is it must to do with client script in your requirement?? 
When you can do it with UI Policy.


***Mark Correct or Helpful if it helps.***

and shouldn't pm be payment?


***Mark Correct or Helpful if it helps.***