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

Robbie
Kilo Patron
Kilo Patron

Hi Jonathan,


Yep, this is easily achieved within a UI policy by leveraging the scripting functionality.


Navigate to the UI policy and ensure you're in the 'Advanced View'. (Available via a link at the bottom left hand side of the screen if not in advanced view)


Firstly, on the 'When to Apply' tab, make sure you set the conditions to Type is Standard (As below)


find_real_file.png



Then, select the 'Script' Tab. Ensure the 'Run Scripts' checkbox is set to true and you can set values based on the Change 'Type' field.


In the below example I'm entering the string 'Testing' in the justification field for Change Requests of type Standard.


find_real_file.png



Please mark correct and/or helpful on your post link (Setting Default Values ) to help close out open questions and aid others with the same/similar question.



Thanks,


Robbie


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

jonathan_77
Mega Expert

Thank you everyone!!   Problem solved!


Hi Jonathan,



Can you please mark the answer as correct so that the thread can be closed.



Regards,


Shloke


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

Regards,
Shloke