As stated in the question. I know I am able to hide/show items depending on the stage of the form.
But what i'm trying to achieve is to hide/show depending on the user role. E.g. show a custom button only to people in "admin" role, but hide it when normal user is accessing the form.
Tried getting it to work by using JavaScript, but it seems that app.getCurrentUser() does not return the user role.
I had a similar requirement in my App where I had to show a link to few Admin users only. Currently Volt does not return Role of a user. Hopefully Volt team will provide this in future releases. As a workaround, I created another Form to save names of few Admin users separated by semicolon in a field. Then I fetched these user names using Service on the Form where I was supposed to hide/show link. Now using javascript I checked if app.getCurrentUser() is part of fetched Admin users field or not and accordingly hide/show link. I used "indexOf" javascript function for this.
P.S. app.getCurrentUser() returns username in canonical form (CN=Test User\O=company). I used common name (Test User) for storing Admin user names. To get common current username I used below code.
var canonical = app.getCurrentUser(); var indx1 = canonical.indexOf('CN=')+3; var indx2 = canonical.indexOf('/'); var common = canonical.substring(indx1, indx2);