Preselect value of Dropdown for different users

This public forum is for user-to-user discussions of PHPMaker. Note that this is not support forum.
Post Reply
WABez
User
Posts: 199

Preselect value of Dropdown for different users

Post 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.


mobhar
User
Posts: 11660

Post 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 ...
}

WABez
User
Posts: 199

Post by WABez »

Thanks. Was a simple mistake, but your input jogged the memory and I manage to solve it.


Post Reply