To display a variable if requested for user is VIP and based on another condition

rishabh31
Mega Sage

Dear Team,

I have the below variables:

1# Requested for (requested_for)-> Reference from sys_user Table

2# access_request_type-> Select Box/Choices: Add, Change, Remove
3# access_change _perma_OR_tempo-> Select Box/Choices: Permanent, Temporary

4# system_access-> Select Box/Choices: SAP, Ops in a box, Resident Portal, Credit Check

5# change_of_access_request-> Select Box/Choices: SAP, Resident Portal, Credit Check, SAP Concur
6# vip_requested_user_requestaccess_locations-> List Collector from cmn_location Table

7# properties_access_require-> Reference from cmn_location Table

 

The requirement is: Variables 6 and 7 should be displayed only when the user selected in variable 1 is VIP (VIP-True) AND variable 2 is one of Add/Change AND variable 3 is one of Permanent/Temporary AND variable 4 is one of SAP/Resident Portal OR variable 5 is one of SAP/Resident Portal.

 

To fulfil this I approached UI Policy/Action (as shown below screenshot)

rishabh31_0-1687597088344.png

 

But Condition part 'user selected in variable 1 is VIP (VIP-True)' is NOT achievable through UI Policy due to which Variables 6 and 7 are getting displayed when the rest mentioned conditions are met, this is not desirable.

 

Please help on how to get this fulfilled. I will mark responses as correct and helpful if resolved.

 

Thanks

 

 

1 ACCEPTED SOLUTION

Arun_S1
Tera Guru
Tera Guru

@rishabh31 I recommend you to

 

1. Create another variable of type (checkbox) called "vip_user".

2. Set that variable "vip_user" to read-only for the time being and hide it later once the requirement is achieved.

Arun_S1_4-1687715154227.png

3.  In the record producer/service catalog navigate to the "Catalog Data Lookup Definitions" tab and create a new record with the below details.

Arun_S1_1-1687714075785.png

4. In the above created catalog data lookup definition "Set VIP User field", navigate to the "Catalog Matcher Definition" tab and create a new record as below. In my case the variable name is "requested_user", you will have to select "requested_for".

Arun_S1_2-1687714207979.png

 

5. Navigate to the "Set VIP User field" catalog data lookup definition created in the step 3 and create a new "Catalog setter variable definition: as below.

Arun_S1_3-1687714469717.png

 

6. In my PDI Abel is non-vip & Aqib is a VIP user and see how the check box behaves for these users.

Arun_S1_5-1687715297923.png

Arun_S1_6-1687715354770.png

 

7. Modify your UI policies to use the 'vip_user' variable.

 

Note: While testing make sure the user is active.

 

Please mark the appropriate response as correct answer and helpful

Thanks!!

View solution in original post

10 REPLIES 10

Manmohan K
Tera Sage

Hi @rishabh31 

 

create on change client script on change of access request with code like below

Change variable names and choices according to your instance configuration

 
var isVip;
var caller = g_form.getReference('requested_for', doAlert); // doAlert is our callback function 
function doAlert(caller) { //reference is passed into callback as first arguments
isVip= (caller.vip == true) ;
}
    var accessRequestType = g_form.getValue('access_request_type');
    var accessChangePermaOrTempo = g_form.getValue('access_change_perma_or_tempo');
    var systemAccess = g_form.getValue('system_access');
    var changeOfAccessRequest = g_form.getValue('change_of_access_request');

    // Check the conditions to show or hide variables 6 and 7
    var showVariables = (isVip) &&
        (accessRequestType == 'Add' || accessRequestType == 'Change') &&
        (accessChangePermaOrTempo == 'Permanent' || accessChangePermaOrTempo == 'Temporary') &&
        ((systemAccess == 'SAP' || systemAccess == 'Ops in a box' || systemAccess == 'Resident Portal') ||
        (changeOfAccessRequest == 'SAP' || changeOfAccessRequest == 'Resident Portal'));

    // Show or hide variables 6 and 7 based on the conditions
    g_form.setDisplay('vip_requested_user_requestaccess_locations', showVariables);
    g_form.setDisplay('properties_access_require', showVariables);

 

 

Thanks @Manmohan K for your response but it is throwing error as shown below screenshot

 

rishabh31_0-1687613887807.png

Thanks

@rishabh31 

 

You would need to add basic skeleton of on change client script like below

 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
var isVip;
var caller = g_form.getReference('requested_for', doAlert); // doAlert is our callback function 
function doAlert(caller) { //reference is passed into callback as first arguments
isVip= (caller.vip == true) ;
}
    var accessRequestType = g_form.getValue('access_request_type');
    var accessChangePermaOrTempo = g_form.getValue('access_change_perma_or_tempo');
    var systemAccess = g_form.getValue('system_access');
    var changeOfAccessRequest = g_form.getValue('change_of_access_request');

    // Check the conditions to show or hide variables 6 and 7
    var showVariables = (isVip) &&
        (accessRequestType == 'Add' || accessRequestType == 'Change') &&
        (accessChangePermaOrTempo == 'Permanent' || accessChangePermaOrTempo == 'Temporary') &&
        ((systemAccess == 'SAP' || systemAccess == 'Ops in a box' || systemAccess == 'Resident Portal') ||
        (changeOfAccessRequest == 'SAP' || changeOfAccessRequest == 'Resident Portal'));

    // Show or hide variables 6 and 7 based on the conditions
    g_form.setDisplay('vip_requested_user_requestaccess_locations', showVariables);
    g_form.setDisplay('properties_access_require', showVariables);
}

 

 

Hello @Manmohan K , thank you for the response but seems it is not checking vip=true for a requested user see the below screenshots.

*Abraham Lincoln is a VIP, in the form requested for is Abraham Lincoln and satisfies other conditions per script, but still its not displaying desired variables 6 and 7-

rishabh31_0-1687669736509.pngrishabh31_1-1687669772042.png

rishabh31_0-1687672717566.png

Just the above screenshot is the each of 7 variable's Question and Name.

NOTE: Since Variables 4 and 5 ('system_access' and 'change_of_access_request') are different variables so I modified your provided script per Onchange of each variable, for example please see the below Onchange CS for Variable 5 'change_of_access_request'-

 

function onChange(control, oldValue, newValue, isLoading) {
   if (isLoading || newValue == '') {
      return;
   }
   var isVip;
var caller = g_form.getReference('requested_for', doAlert); // doAlert is our callback function 
function doAlert(caller) { //reference is passed into callback as first arguments
isVip= (caller.vip == true) ;
}
    var accessRequestType = g_form.getValue('access_request_type');
    var accessChangePermaOrTempo = g_form.getValue('access_change_perma_or_tempo');
    //var systemAccess = g_form.getValue('system_access');
    var changeOfAccessRequest = g_form.getValue('change_of_access_request');
    // Check the conditions to show or hide variables 6 and 7
    var showVariables = (isVip) &&
        (accessRequestType == 'Add' || accessRequestType == 'Change') &&
        (accessChangePermaOrTempo == 'Permanent' || accessChangePermaOrTempo == 'Temporary') &&
        (changeOfAccessRequest == 'SAP' || changeOfAccessRequest == 'Resident Portal');
    // Show or hide variables 6 and 7 based on the conditions
    g_form.setDisplay('vip_requested_user_requestaccess_locations', showVariables);
    g_form.setDisplay('properties_access_require', showVariables); 
}

 

Need help to get this resolved.

Thanks