How to make a warning popup upon clicking a UI button?

mitzaka
Mega Guru

Hi SNC,

 

I have a UI button which refers to a certain action (example: Reject) and I want when someone clicks this UI button, that he receives a message to fill a field before anything else happens. I know I could do a UI policy where I can make the field mandatory, but if I make it mandatory I have to use a condition based on state and I don't want to do this because in this state I have another UI buttons on the form like Approve, Publish, etc.

Is there a way I can say that the field will become mandatory only when a specific button is pressed?

Thanks in advance.

1 ACCEPTED SOLUTION

harikrish_v
Mega Guru

Hi Dimitar,



You can refer to the second script in this guru link, I guess this is what you are looking for:-



http://www.servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/



Regards,


Hari


View solution in original post

5 REPLIES 5

Subhajit1
Giga Guru

Hi Dimitar,


Upon clicking the UI Action button, you can set a Flag field value to true.


This Flag field need to be on the form, but you can hide this field unconditionally using a UI Policy.


Now using another UI Policy you can set any other field Mandatory on the basis of your Flag field turning True.



Hope this helps.



Thanks,


Subhajit


Hi Dimitar,



I suggest you can write a On Submit client script like



var ex = g_form.getActionName();


if(ex == 'Reject'){


g_form.setMandatory('field',true);


}



Let me know if you have any question.



Regards,


Sunil Babu Safare.


harikrish_v
Mega Guru

Hi Dimitar,



You can refer to the second script in this guru link, I guess this is what you are looking for:-



http://www.servicenowguru.com/system-ui/ui-actions-system-ui/client-server-code-ui-action/



Regards,


Hari


Harikrishnan Vijayanabsolutely what I was looking for! Thanks a lot!:)