I have one form laid out in tabs and wish to set some fields as read only based on the userlevel of a group. Those same fields should allow insert of data for another group. How can that be done?
You can set the the field to read only in the Row_Rendered server event depending on condition. For example:if (…) // Set up your condition here
$this->field->ReadOnly = TRUE;
Thanks! It works but there is another issue. I have a vacation leave form. The person applying for leave fills out part of the form and the supervisor and another person may add comments etc to the same form. My plan has been to give the person applying for vacation, the role of applicant. In order to limit him/her to only his part of the form, I have set the parts belonging to the supervisor to readonly. Example:if (CurrentUserLevel() == 1) //the userlevel of the applicant
$this->SupervisorRec->ReadOnly = True; //a field set to readonly, when the applicant is logged in.
$this->Comments->ReadOnly = True;For the supervisor, I want the readonly to be removed from the same fields.
if (CurrentUserLevel() == 2) //Userlevel of the Supervisor
$this->SupervisorRec->ReadOnly = False;
$this->Comments->ReadOnly = False;However, the fields are remaining as readonly even when the Supervisor is logged in. In fact, they remain as readonly even when the hard-coded Administrator is logged in.
What am I doing wrong?
Just correcting my statement above. The readonly status is take off the fields for the supervisor but in the process, it is also no longer readonly when the applicant with UserLevel 1 is logged in and clicks the Add Button to create another vacation leave request.
The second line of your ReadOnly is always run. Make sure that you quote your condition with curly brackets. For example:if (…) {
$this->Field1->ReadOnly = TRUE;
$this->Field2->ReadOnly = TRUE;
}
This is how it looks:function Row_Rendered () {if (CurrentUserLevel() == 1) { //the userlevel of the applicant
$this->SupervisorRec->ReadOnly = True; //a field set to readonly, when the applicant is logged in.
$this->Comments->ReadOnly = True;//For the supervisor, I want the readonly to be removed from the same fields.
if (CurrentUserLevel() == 2) { //Userlevel of the Supervisor
$this->SupervisorRec->ReadOnly = False;
$this->Comments->ReadOnly = False;
}
}
}Whlie the fields are set to readonly when the user with UserLevel 1 is logged in, when the UserLevel 2 is logged in, someone after, logging in with Level would find that at least one field is no longer readonly.
you have if (CurrentUserLevel() == 2) {} blocked withinif (CurrentUserLevel() == 1) {}so if the if CurrentUserLevel() == 1 then it can’t also be CurrentUserLevel() == 2is this what your asking:if (CurrentUserLevel() == 1) { //the userlevel of the applicant
$this->SupervisorRec->ReadOnly = True; //a field set to readonly, when the applicant is logged in.
$this->Comments->ReadOnly = True;
} else if (CurrentUserLevel() == 2) { //Userlevel of the Supervisor
$this->SupervisorRec->ReadOnly = False;
$this->Comments->ReadOnly = False;
}
else {
add a default state to the fields here if its a different userlevel or initial at rest state of the fields
}or do it in a switch (CurrentUserLevel()) {}
Thanks much.