How to make field visible and make mandatory when we change value from field 1 to field2?

Ramu6
Tera Contributor

Hi All,

 

Actually we have  three reference fields(Assigned to , Secondary officer, Primary Officer), so here whenever incident created these are empty and we assigned one officer, now the requirement was like

1) if for example when incident created three are empty so when we try assigned one of them there is one more field "Remarks " will not display

2)if for example after created i selected "Assigned " field value and save the form, after if user trying to change that value to another then remarks field will appear and mandatory

3)And next scenario continuation to above one, if user want to change the other field value like , making "Officer" field value as empty and if he want to select "Primary Officer" value , then also remarks field will appear and mandatory

And vice versa for others as well

 

Please help me to complete this

Thanks

Ramu

7 REPLIES 7

Mark Manders
Mega Patron

You can achieve this through a couple of onChange client scripts. You can use setVisible() and setMandatory() on those fields. 


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

@Mark Manders 

Thanks for the response , Actually we have written onchange client scripts for the fields , but those are working individually only, not working when we try to change between two fields

 

this is the client script we wrote all three fields 

 

Ramu6_0-1722316659463.png

 

An onChange client script only runs on 1 field when it changes. You will have to apply a client script for each field that needs to do something when it changes.


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark

Mark Manders
Mega Patron

https://www.servicenow.com/community/csm-forum/how-to-make-field-visible-and-make-mandatory-when-we-...


Please mark any helpful or correct solutions as such. That helps others find their solutions.
Mark