how can I make field ReadOnly after submission of form?

Tejas16
Tera Contributor

suppose there is custom table say(Student) having a Email field and before submission of form email is auto populate.

As soon as form is submitted the email field must set to Read Only. and when user open the same record in default view of form  'email' field must set to read only.

But When I open the same record the email field in default view of form  
is not Read Only?

plz check below client script which is of type onsubmit.
can any one help me out of this issue?

function onSubmit() {

var studName = g_form.getValue('u_name');
var separateName = studName.replace(/\s/g,'');
var course = g_form.getValue('u_course');
g_form.setReadOnly('u_student_email',true);
g_form.setValue('u_student_email',separateName+course+'@demo.com');

}

2 REPLIES 2

Anil Lande
Kilo Patron

Hi,

write OnLoad client script and use below logic:

function onLoad() {
	if(!g_form.isNewRecord()){
		g_form.setReadOnly('u_student_email',true);
	}
}

 find_real_file.png

Thanks,
Anil Lande

Please appreciate the efforts of community contributors by marking appropriate response as correct answer and helpful, this may help other community users to follow correct solution in future.
Thanks
Anil Lande

Aman Kumar S
Kilo Patron

Hey,

You don't need onsubmit for this, you can have a UI policy in place for this.

You can put condition in the UI policy as Email is empty, then in UI policy action of the field you can set the field as read only true. 

This will resolve your issue.

Best Regards
Aman Kumar