Editing read only fields (ACL)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2017 06:58 AM
Hello,
I'm struggling to come up with the best way to accomplish the following.
I have a field on the project table called "Go live date" and I would like to be read only if the field has a date set. If there is no set date then anyone can enter a date but doing this will lock the field out so the date can't be changed.
What I would then like is to allow a designated user with a specific role to be able to change that field whenever needed.
I'm not very good at scripting (still learning) and don't seem to be able to accomplish this using conditions in an ACL.
Does anyone have any suggestions?
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2017 07:48 AM
This is what I currently have:
function onLoad() {
var golive = g_form.getValue('u_go_live_date');
if ( golive != '') {
g_form.setReadonly('u_go_live_date',true);
}
{
var admin = g_user.hasRole('bc_it_project_admin');
if (admin == 'true');
g_form.setReadOnly('u_go_live_date',false);
}
}
However a user who doesn't have the bc_it_project_admin role is still able to change the date in the field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2017 07:49 AM
Hi,
You can use like this.
function onLoad() {
var golive = g_form.getValue('u_go_live_date');
var admn = g_user.hasRole('bc_it_project_admin');
if ( golive != '' && admn == false ) {
g_form.setReadonly('u_go_live_date',true);
}
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2017 07:58 AM
You hero! perfect!
As you could see, still learning the scripting side of thing - this worked a treat and thank you!.. however I can't seem to set your response as the correct answer =(
Thank you to everyone.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2017 08:24 AM
You shouldn't have to do any scripting for this.
The Condition Builder of the UI Policy is only the first part. After you have your Condition Built, you have to add Variables/Fields to it that you want to control with that Condition. Here is an example for Incident Category/Subcategory.
For your 'All Access Role', try setting that as an ACL by right clicking on the field to bring up its Dictionary. Once there, Elevate yourself to 'Security Admin' to be able to add additional ACLs and create a new ACL based on the desired Role.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-04-2017 09:07 AM
Agreed - a combination of UI Policy and ACLs should achieve what you're after without any scripting.
As a general rule of thumb: scripting should be considered the last option when all other avenues have been exhausted.