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

Setting Default Values

jonathan_77
Mega Expert

Is there a way to set a default value by using a UI Policy?   I am making some changes to our change_request form.   We have 3 types of Change Requests:

  1. Normal
  2. Standard
  3. Emergency

If Emergency is selected, I need the Out Of Band value to be automatically be defaulted to yes or true.   If it is a Standard or Maintenance, I need to Out Of Band field to still show but not default to Yes\True or No\False.   I know I can set a default value on the dictionary entry but that would default Out of Band for all 3 categories which isn't what I need to happen.   Thanks for any feedback!

1 ACCEPTED SOLUTION

shloke04
Kilo Patron

Hi,



Write an On Change Client script with the Field Name selected as Change Type field having values "Emergency, Normal etc. Below code should work for your requirement:



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


    if (isLoading || newValue === '') {


          return;


    }


if(newValue=='Emergency')


{



g_form.setValue('Field Name',true);


}


else if(newValue == 'Normal')


{


g_form.setValue('Field Name',true);


}


}



Note: Replace the field Name in the script above with the exact Field Name you want to set the value for.



Hope this help. Mark the answer as correct/helpful based on impact.



Regards,


Shloke


Hope this helps. Please mark the answer as correct/helpful based on impact.

Regards,
Shloke

View solution in original post

5 REPLIES 5

Hi Jonathan,


Glad you/we resolved it.


Please can you mark my response correct and helpful by clicking on your post link (Setting Default Values ) to help close out open questions and aid others with similar questions.



PS - The reason to implement this via a UI policy over a client script is that the UI policy will only be called when the condition is met, and not on every load.



Thanks,


Robbie