UI Policy which only applies for a new form record

Simon Ciglia
Giga Guru

Hi folks

I need a UI Policy which only applies for a new form record.

Any ideas?
Any help is appreciated, thank you in advance.

Simon

1 ACCEPTED SOLUTION

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi,

if you need to make a field mandatory, visible or read only for a new record, then it's better to use an onLoad client script with the isNewRecord() function, see an example below:

if(g_form.isNewRecord()){  

g_form.setMandatory('field_name', 'true');   ////provide field name here

}

else{

g_form.setMandatory('field_name', 'false');

}

If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.

Thank you

Cheers
Alberto

View solution in original post

5 REPLIES 5

Harsh Vardhan
Giga Patron

you need to use g_form.isNewRecord() in ui policy script part. that way you can identify the record is new or existing. 

 

use script part to make the field read only , mandatory and visible 

Alberto Consonn
ServiceNow Employee
ServiceNow Employee

Hi,

if you need to make a field mandatory, visible or read only for a new record, then it's better to use an onLoad client script with the isNewRecord() function, see an example below:

if(g_form.isNewRecord()){  

g_form.setMandatory('field_name', 'true');   ////provide field name here

}

else{

g_form.setMandatory('field_name', 'false');

}

If I have answered your question, please mark my response as correct so that others with the same question in the future can find it quickly and that it gets removed from the Unanswered list.

Thank you

Cheers
Alberto

Harsh Vardhan
Giga Patron

sample script:

 

if(g_form.isNewRecord()){

 
  g_form.setMandatory('field_name', 'true');

 
}

 

Sushant Kadam1
Kilo Guru

Hi Simon,

You can use method "isNewRocord()" from GlideForm in your script part.

eg.  if(g_form.isNewRecord())

      {

           // some code

      }

 

Please mark helpful or correct if you feel needful.

thanx,

Sushant