How to set a Priority field value onLoad only

ss123
Tera Contributor

Hi!

 

We have a requirement where we need to set the Priority to field to --None-- (this is from the Dropdown with None) when a case form is newly created and HR Service = "HRServ1" (sample only)

 

I achieved this using UI Policy but the problem is, when we changed the Priority value to other options then click  Save or Update button, it goes back to Priority value "--None--"

 

Thanks in advance

1 ACCEPTED SOLUTION

Harish KM
Kilo Patron
Kilo Patron

Hi UI Policy will not work for this since it will run on each onload, you can go for before insert Business rule and set priority to none as this BR will run only once that is during case creation.

HarishKM_0-1690339127552.png

HarishKM_1-1690339140571.png

 

Regards
Harish

View solution in original post

11 REPLIES 11

@Tony Chatfield1 thanks. I am also trying to use this Client Script 

SabrinaSalazar_1-1690334059828.png

Not working. Can you please help check if I am missing something?

Thanks

Tony Chatfield1
Kilo Patron

Hi, unfortunately it is not possible to test a screenshot, but I can test the basic principle behind your code in a PDI using incident.impact and it works as expected field is set to -- None -- on load and is not reset to this value once the form is saved and reloads.

function onLoad() {
    if (g_form.isNewRecord()) {
        g_form.setValue('impact', '', '-- None --');
    }
}


I can see in your screenshot the script is Active = false, perhaps this is the issue?
Or possibly you have other functionality impacting the record
- you previously mentioned a UI policy solution, is this disabled?

Is there any other OOB code in HR that could be impacting the result?

Tried to investigate but I don't see any configurations that might be affecting this. 

 

When I tried this below script it doesn't change the onload value of Priority field.

 

function onLoad() {
    if (g_form.isNewRecord()) {
     if (g_form.getValue('hr_service') == '4889bf131b8f6b00461376e1dd4bcb43') {
        g_form.setValue('priority, '', '-- None --');
    }
}
}

 

 

But when I tried this, it sets the Priority field to --None--, but it goes back after saving. 😞

 

 

if (g_form.getValue('hr_service') == '4889bf131b8f6b00461376e1dd4bcb43') {
            g_form.setValue('priority', '',   '-- None --');

 

  

Harish KM
Kilo Patron
Kilo Patron

Hi UI Policy will not work for this since it will run on each onload, you can go for before insert Business rule and set priority to none as this BR will run only once that is during case creation.

HarishKM_0-1690339127552.png

HarishKM_1-1690339140571.png

 

Regards
Harish

ss123
Tera Contributor

@Harish KM thanks! I believe there's something interfering this configuration I 'll have to check.