Please enable JavaScript to view this site.

Navigation: Advanced topics > Events > Sample events > Appearance

Hide controls on Add/Edit pages, based on the username

Scroll Prev Next More

 

To hide controls on Add/Edit pages, based on the username, use the following code in the Add Page: BeforeDisplay and/or Edit Page: BeforeDisplay event.

Example 1

To show the Horsepower field edit control only if the username equals "admin", use the following code:

 

if Security_getUserName()<>"admin" then
 pageObject.hideField("Horsepower")
end if

Example 2

To show the Horsepower field edit control only if the current user belongs to the admin group, use the following code:

 

if Security_isAdmin() then
  pageObject.hideField("Horsepower")
end if

 

Note: This code sample works only with static permissions.

 

3. To hide the Horsepower field edit control placed on tab or folding section on the Edit/Add/View page, use the following code:

 

pageObject.hideField("Horsepower")

See also:

Security API

JavaScript API: hideField()

Security API: isAdmin

Security API: getUserName

JavaScript API: hide()

RunnerPage class: hideItem()

JavaScript API: toggleItem()