hcl-bot
November 6, 2007, 12:45am
1
Dear all,Please help me to use this following formula on web…this gives an error on page
Shana
@If (@IsMember (“[Administrator]”; @UserRoles ); “”;@Return (@Prompt ([Ok];“Information”;“Sorry ! You are not authorised to Use this function”)));
@Command ([OpenFrameset];“Admin_FS”)
Subject: @formula on web
@Prompt doesn’t work on the web. You’ll have to find some other method of presenting a message, such as Javascript or simply putting the message in a field on the form for the user to see.
Subject: RE: @formula on web
thanks…How can i use JS to check userroles on a page…
Subject: RE: @formula on web
Try this, place the following forumla in the form’s “HTML Head Content” or a computed text at the top of the form:
“<script type="text/javascript">”+
"var USER_ROLES = new Array(\"" + @Implode(@UserRoles;"\",\"") + "\");"+
"function doesUserHaveRole(sRole){"+
"var hasRole = false;"+
"for(var i = 0 ; i < USER_ROLES.length ; i++){"+
"if(USER_ROLES[i] == sRole){"+
"hasRole = true;"+
"}"+
"}"+
"return hasRole;"+
"}"+
“”
Then use javascript similar to this in your submit button:
//---------------------------------
if(!doesUserHaveRole(‘[Administrator]’){
alert(‘Sorry, you cannot access this page!’);
}else{
var framesetURL = “Admin_FS”; //you may have to tweak this
top.document.location.href = framesetURL;
}
//----------------------------------
hcl-bot
November 8, 2007, 12:15am
5
Subject: RE: @formula on web
Thanks a million…
Subject: RE: @formula on web
Or can’t you simply hide the object (button?) that would open the frameset for those who are allowed to?