The CreatorCon Call for Content is officially open! Get started here.

UI Policy Catalog Conditions Related Fields

rahulmishra
Kilo Contributor

I have a requirement that states make   "Phone " field mandatory and visible on a form if it is empty in   "User" Table for the user selected on form.

I have to perform these actions using UI Policy only.

The script should be as minimum as possible.

How can I add a new field to related fields list in Catalog conditions for a UI Policy.

Please suggest some solution.

5 REPLIES 5

HarshTimes
Tera Guru

Hi Rahul


The best approach will be to create a glideajax call to check the users phone. See the below doc to understand how the glideajax work


Examples of asynchronous GlideAjax



There is another below script using the getReferencethat will also work , but this is not suggested as a good approach from performance perspective.



var usr = g_form.getReference('USER_FIELD_NAME', iSPhEmpty);



function iSPhEmpty(usr){


if (usr.phone == '')


    g_form.setMandatory("PHONE_FIELD_NAME",true)



}


Hello Harsh,



Thanks for the response.


.


Can't this be done using conditions in UI policy?


How can I specify change of user in conditions   and refer "Phone" field in User Table?


There is "user" variable on form which refers "User" Table


Unfortunately not, We cannot dotwalk the variable in the condition field.The dot walk of the reference fields in the condition work only for the actual field on the table.



-Harsh


Preetam Barai
Tera Expert

Hi Rahul,



try a onchange client script.



  1. function onChange() {  
  2. }  
  3. var ph= g_form.getValue('user.mobile_phone'); //dot walking to the user phone filed.
  4. if(ph == ''){
  5.     g_form.setMandatory('variables.example1', true);   //variables.'your variable name'
  6. }  


Hope this helps.