Make a field Read Only if value is not NULL

George P
Tera Guru

I need to make a field read only after a value has been selected.  But I need this to be affective in all views, not just on the form (e.g. List edit is also read only).  I assume this is some kind of script, but I am fairly new at scripting and could use some guidance.

1 ACCEPTED SOLUTION

Hi,

1.You can use UI policy to make any field read only if it is not empty(form View).

1.1 you can also use OnLoad Client script to make field read only

1.2 

var a= g_form.getvalue("Field");

if(a!=''")

{

//Two Variable pass as a parameter

g_form.SetReadOnly('field',true);

}

 1.3 But my suggestion you can use UI policy because it's priority is greater then Client Script.  

2.You can use ACL to make field read only.(List VIew)

Thanks,

Vikas

View solution in original post

8 REPLIES 8

I used your code as a start and used a UI Policy to set Read Only on the form.  Thanks for the help.

I am going to hold off on the ACL for now because I don't think we are going to teach the users to modify tickets from the list anyway.  I'll revisit if needed.

Hi,

1.You can use UI policy to make any field read only if it is not empty(form View).

1.1 you can also use OnLoad Client script to make field read only

1.2 

var a= g_form.getvalue("Field");

if(a!=''")

{

//Two Variable pass as a parameter

g_form.SetReadOnly('field',true);

}

 1.3 But my suggestion you can use UI policy because it's priority is greater then Client Script.  

2.You can use ACL to make field read only.(List VIew)

Thanks,

Vikas

Good Morning Murthy,

In your script what does you if statement mean?  Is that where you put the field value?  I did it this way and it didnt work.

function onLoad() {
//Type appropriate comment here, and begin script below

var a= g_form.getvalue("eis_classification");
}
if(a!='Internal')

{

//Two Variable pass as a parameter

g_form.SetReadOnly('field',true);

}

 

Thank you

Hi @Darlene York 

Yes it gives the field value. Keep some alert and get the value and paste the same value in if conditon like below:

function onLoad() {
//Type appropriate comment here, and begin script below
var a= g_form.getvalue("eis_classification");
alert(a);  //gives the value paste the same value in below if condition and check
}
if(a!='Internal') //paste the alert value here
{
//Two Variable pass as a parameter
alert("inside if"); //check if this alert is coming or not..
g_form.SetReadOnly('field',true);  //replace with actual field name 
}

Hope it helps.

 

Thanks,
Murthy