Exclude option from Choice Column in New Item based on SharePoint Permission Groups
Is there a way to exclude choice A from the list in the dropdown and only show choice A if the person is a member of the Owner's group?
Example:
Current Choice Selections - A, B, C
Choice Selections Available for everyone outside the Owners group - B, C
Option A should always be excluded and only visible to the Site Owners.
Can you assist me with this javascript function or something similar?:
var array = [[Status]];
var index = [[Status]].indexOf("PO Requested","PO Approved", "PO Closed", "Close PO", "GR Requested", "GR Complete") && [[@User.IsMemberOfGroup('Owners')]];
array.splice(index, 6);
return array;
Or maybe a visibility formula?
[[@User.IsMemberOfGroup('Owners')]],
[[Status]] == "PO Requested", "PO to be Created", "PO On-Hold Pending Documents", "PO On-Hold Pending Funds", "PO On-Hold Pending Vendor Creation", "PO Pending Approval", "PO Approved", "PO Closed", "Close PO", "GR Requested", "GR On-Hold Pending Funds", "GR Complete")
[[Status]] == ("Request a PO","Request a GR")
Thank you for your assistance!
-
Hi Maria
Choice Columns doesn't have any built-in filter possibilities in Modern Forms.I would suggest to maintain your Status values in a separate list and reference it by a lookup column.
This gives you the possibility of filtering on related forms:
After creating a new list with all the status values and setting a lookup on the list with forms in question:
1. Open the Field configuration of the new lookup field
2. Create a new filter
3. Add this condition to only apply the filter if the user is not part of the Owners group:=![[@User.IsMemberOfGroup('Owners')]]
4. Get the status values which should be shown and selectable for everybody
Hope this helps - please let us know.
0 -
Hello Skybow support,
This solution is not working. When I add the values and test the dropdown is empty. There is no way to use the column I already have on the form and use a javascript function to achieve this? The status column has been in use for quite some time and I will have to bring all of the status values from all of the older submissions if I move ahead with this suggestion. Thank you for your time.
0 -
I just tested this with another user and the drop-down values are not displaying with this filter. I appreciate your assistance with this request.
0 -
Can we try something like this? https://my.skybow.com/hc/en-us/community/posts/7608200555164-Add-List-Item-Exclude-option-from-Choice-Column-in-New-Item
0 -
Does the Rule/Condition need to be an assignment or Template. I cannot get it to work how you have it in the screenshot. thank you for your assistance
0 -
Hi Maria
My mistake... Needs to be an Assignment Expression in the Rule/Condition (starting with an = character). Just changed in the answer above.1 -
Hi Maria
There is an approach by adding some custom code + css to hide the specific options in the dropdown on form load.1) 2) Create a new Execute script action in the Form Load Actions (Pre-Form Load):
3) Add this code to the Execute script Action:
$('head').append(`<style type="text/css">
div.sb-dropdown-option[title="On Hold"],
div.sb-dropdown-option[title="Cancelled"],
div.sb-dropdown-option[title="Archived"] {
display: none;
}
</style>`);Replace the option names in the script above with your own values.
4) Use the following Expression as Condition for the Action (Assignment):
![[@User.IsMemberOfGroup('Owners')]]
Hope this works for you. Please let me know!
2 -
This worked! Thank you very much for the solution Christof!
0
Please sign in to leave a comment.
Comments
8 comments