
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2020 02:29 AM
Hi Community
I have a problem with the OOB UI Action "Edit...". Condition of this UI action is:
(new GlideRecord(current.getTableName())).canCreate() && RP.isManyToMany() && !RP.getListControl().isOmitEditButton()
Now on my User Group table, I want that only the group owner can see and use the "edit" button on the related list "Group Members". Therefore I edited the list control and added following omit edit button script:
var answer = true;
if(current.group.manager == gs.getUserID() || gs.hasRole('admin')){
answer = false;
}
answer;
Now when a non-group-owner user opens the form, the edit button is omitted. If a group owner opens the form the edit is there but clicking it results in an "action not authorized". After investigating I know its the "!RP.getListControl().isOmitEditButton()" condition on the UI action. If I remove this everything works as expected.
Does anyone have an idea what's the cause?
Thank you in advance, regards
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-20-2020 01:17 AM
Problem solved!
In a list control of related list access to the main record displayed on the form you need to use "parent", and not "current" like I did. "Current" refers to the first entry of the related list.
So following list control omit edit function works like desired:
var answer = true;
if(parent.manager == gs.getUserID() || gs.hasRole('admin')){
answer = false;
}
answer;
Thanks everyone 🙂

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2020 03:20 AM
Hi,
It seems like your facing same issue,please go through it.
Cause
This is controlled by the condition on the Incident 'New' UI Action (sys_ui_action.do?sys_id=bb80a37c0f320000b12e6903cfe01218), where it has '!RP.getListControl().isOmitNewButtonWithoutChecks()' defined:
current.canCreate() && !RP.getListControl().isOmitNewButtonWithoutChecks() && RP.isRelatedList() && !RP.isManyToMany()
Resolution
Change the condition defined against the Incident 'New' UI Action to '!RP.getListControl().isOmitNewButton()':
current.canCreate() && !RP.getListControl().isOmitNewButton() && RP.isRelatedList() && !RP.isManyToMany()
This will then allow the 'Omit new condition' field script to run.
Please mark correct if helps you.
Ali Shaikh.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2020 03:39 AM
Hi Ali
thanks for your quick response. If I understand correctly I am not facing the same problem as you described there. I ain't using the "!RP.getListControl().isOmitNewButtonWithoutChecks()", as you see in my problem description the current condition in place is:
(new GlideRecord(current.getTableName())).canCreate() && RP.isManyToMany() && !RP.getListControl().isOmitEditButton()
So either I didn't understand you correctly or your answer doesn't match my question.
Thank you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2020 05:26 AM
Hi ,
current.canCreate() && !RP.getListControl()..isOmitEditButton() && RP.isRelatedList() && !RP.isManyToMany()
Please use this code.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎03-19-2020 07:18 AM
Hi,
I tried your code (although I think the ".." is a typo). Just to clarify I tried all of these conditions:
current.canCreate() && !RP.getListControl()..isOmitEditButton() && RP.isRelatedList() && !RP.isManyToMany()
Can't save because of the ".." typo.
current.canCreate() && !RP.getListControl().isOmitEditButton() && RP.isRelatedList() && !RP.isManyToMany()
The button is not displayed anymore.
(new GlideRecord(current.getTableName())).canCreate() && RP.isManyToMany() && !RP.getListControl().isOmitEditButton()
OOB condition, the button is displayed but on click, I get "action is not authorized".
(new GlideRecord(current.getTableName())).canCreate() && RP.isManyToMany()
This one works completely (but is missing the isOmitEditButton function).
I have no idea why this can even happen. I assume the condition itself works because the button is displayed. I also don't know why a click on the button does trigger the condition again (I assume it has to because if I remove the isOmitEditButton() function on the condition the button click works).
Someone any more ideas?