- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2014 03:01 PM
I am trying to make the state field on an approval form read_only, except for admin role, and also if the current user is the approver. I have set up a UI Policy to do this,but it doesn't appear to like the current user. This is the script I have in the Execute if true script:
function onCondition() {
if ((g_user.userID == g_form.getValue( 'approver' )) || (g_user.hasRole("admin"))) {
g_form.setReadOnly( "state", false );
} else {
g_form.setReadOnly( "state", true );
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2014 07:04 AM
are using Calgary too and we use an ACL
type: record
operation: write
active: yes
admin overwrite: yes
name: sysapproval_approver state
Add a condition if you want (we have state is not "Not valid for this change"
script: answer = gs.hasRole('approval_admin') || isApprovalMine(current);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2014 04:50 PM
Thanks niedziel,
unfortunately, we are still on Calgary (I check Dublin too) and the 'is (dynamic) ' option must be a Eureka enhancement as I don't have it available.
Cheers, Mark S.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2014 04:55 PM
Curious you don't see it on dublin...that is when the feature was added. It is the last choice on the operator list when building a condition for a reference field that points at the sys_users table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-17-2014 07:17 PM
You don't need "reverse if false".
But I believe your original should work if you clear out the condition.
I created and tested the following script in Calgary and it worked exactly as you want.
function onCondition() {
if (g_user.userID == g_form.getValue('approver') || g_user.hasRole('admin')){
g_form.setReadOnly('state',false);
} else {
g_form.setReadOnly('state',true);
}
}
However, if this should have an effect across the system, a UI policy isn't the place to do this.
Take a look at write ACLs, you can use current.approver there and it does a much more thorough job of preventing the state from being manually changed by someone without authority.
Thanks,
-Stephen
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2014 07:04 AM
are using Calgary too and we use an ACL
type: record
operation: write
active: yes
admin overwrite: yes
name: sysapproval_approver state
Add a condition if you want (we have state is not "Not valid for this change"
script: answer = gs.hasRole('approval_admin') || isApprovalMine(current);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-18-2014 05:47 PM
Thanks again for all the responses. As pointed out, I did go the ACL route, and it was just what I needed. I will mark this as answered.