Page 1 of 1
Preselect value of Dropdown for different users
Posted: Tue Dec 06, 2022 3:33 am
by WABez
I want to improve user experience by "preselecting" a value from a dropdown list based on the user that is logged in (on the ADD page), i.e.:
User 1, User 3, User 3 = Option 1 (is selected as default)
User 2, = Option 3 (is selected as default)
User 4, User 5 = Option 2 (is selected as default)
When any of these user add a new record, I want to "preselect" the value relevant to them, instead of the user having to click and select the item.
I'm adding my code to: Server Events > Global > Table Specific > Add/Copy Page > Page_Render, but somehow I cannot seem to get a "default" value "set" in the dropdown box.
Re: Preselect value of Dropdown for different users
Posted: Tue Dec 06, 2022 8:43 am
by mobhar
You may use Row_Rendered server event, for example:
// adjust the code to your needs!
if (CurrentPageID() == "add") {
if (CurrentUserName() == "user01" || CurrentUserName() == "user03") {
$this->YourFieldName->CurrentValue = "option01";
} elseif (CurrentUserName() == "user02") {
$this->YourFieldName->CurrentValue = "option03";
} elseif (CurrentUserName() == "user04" || CurrentUserName() == "user05") {
$this->YourFieldName->CurrentValue = "option02";
} // and so forth ...
}
Re: Preselect value of Dropdown for different users
Posted: Tue Dec 06, 2022 1:50 pm
by WABez
Thanks. Was a simple mistake, but your input jogged the memory and I manage to solve it.