Hiding the variables of catalog item in portal based on requested email

Radhika devi
Tera Contributor

i want to hide few checkboxes on portal page of a catalog item based on requested by email variable

example: if requested by email ends with path.us then show only few boxes, hide remaining boxes

i tried creating UI policies and client scripts but no use, can anyone help in this regard please...

1 ACCEPTED SOLUTION

@Radhika devi Could you please try the following and let me know if it works.

 

function onChange(control, oldValue, newValue, isLoading) {
    if (isLoading) return;
    g_form.getReference('requested_by_email', function(requestedBy) {
        if (requestedBy && great_plains == 'true') {
            if (requestedBy.email.endsWith("wellpath.us")) {
                g_form.setDisplay('corp_director_of_accounting', true);
                g_form.setDisplay('corp_sub_senior_accountant', true);
            }
        } else {
            g_form.setDisplay('corp_director_of_accounting', false);
            g_form.setDisplay('corp_sub_senior_accountant', false);
        }
});
}

View solution in original post

17 REPLIES 17

J Siva
Tera Sage

Hi @Radhika devi 

You can use Catalog UI policy to achieve this.

1. Create one hidden variable to store the email address of "Requested by"

2. Create one catalog UI policy with condition "email contains path.us"

3. In UI policy action control the visibility of the check boxes.

Hope this helps.

Let me know if you need any assistance.

Regards,

Siva 

Hi @J Siva ,

I have tried doing the same but email contains path.us is not executing and filtering the records, i tried includes also but no change in output

 

Hi @Radhika devi 

Could you share the screehsot of your UI policy?
I just tried the scenario in my PDI and it's working as ex[ected. PFB.

1. Catalog variables:

JSiva_0-1744687024310.png

JSiva_1-1744687103685.png

2. UI Policies:

1)

JSiva_2-1744687157859.png

JSiva_3-1744687184591.png

2) 

JSiva_4-1744687223169.pngJSiva_5-1744687248294.png

 

Outputs:

JSiva_6-1744687299650.pngJSiva_7-1744687332736.png

 

 

 

 

Sandeep Rajput
Tera Patron
Tera Patron

@Radhika devi Could you please share what you have tried so far? This can be easily done via an onChange script on the requested by field. 

function onChange(control, oldValue, newValue, isLoading) {
  if (isLoading) return;

  // Use getReference with a proper callback function
  g_form.getReference('requested_by', function(requestedBy) {
    if (requestedBy && requestedBy.email) {
      if (requestedBy.email.endsWith("@external.com")) {
        g_form.setDisplay('checkbox_1', false);
        g_form.setDisplay('checkbox_2', false);
      } else {
        g_form.setDisplay('checkbox_1', true);
        g_form.setDisplay('checkbox_2', true);
      }
    } else {
      // In case email is not found or user is null
      g_form.setDisplay('checkbox_1', true);
      g_form.setDisplay('checkbox_2', true);
    }
  });
}