Page 1 of 1

Set Field as Read Only Based on User Level

Posted: Sun Nov 27, 2022 9:49 pm
by aspsteve

First of all, I would like to apologize for the quality of the code below, as I am not a programmer.

However, I would like to make a field read only and set the value of the field to a default value based on User Level. If they are not in any of those two user levels (4 and 6), then they should be able to updated the field with a value

Please see my attempt at doing this which is throwing an error

I am using the Row Rendered Function

// Row Rendered event
public void Row_Rendered() {
    //VarDump(<FieldName>); // View field properties
if CurrentUserLevel() == "6"?:
{
SelfServiceUserName.EditValue = "Not Authorized";
SelfServiceUserName.EditCustomAttributes = "readonly=\"readonly\"";
if CurrentUserLevel() == "4"?: 
{
SelfServiceUserName.EditValue = "Not Authorized";
SelfServiceUserName.EditCustomAttributes = "readonly=\"readonly\"";
Else 
	SelfServiceUserName.EditCustomAttributes = "not changed";
}
}

Re: Set Field as Read Only Based on User Level

Posted: Mon Nov 28, 2022 6:27 am
by MichaelG

It should be something like:

if (...) {
Field.EditValue = "...";
Field.ReadOnly = true;
} else if (...) {
//...
} else {
//...
}

Re: Set Field as Read Only Based on User Level

Posted: Thu Dec 15, 2022 4:00 am
by aspsteve

Thank you very much. This worked