Is there a way to add a saved search that says if ...
# general
l
Is there a way to add a saved search that says if the current user’s role is in any of the roles in the next approvers’ roles (multi-select field), then show it? {userrole} retrieves the internal ID of the current user’s role. I tried the following below: CASE WHEN {nextapprover.id}={user.id} OR {custbody_next_approver_roles.id} LIKE ‘%’||{USERROLE}||'%' THEN 1 ELSE 0 END CASE WHEN {nextapprover.id}={user.id} OR {USERROLE} IN ({custbody_next_approver_roles.id}) THEN 1 ELSE 0 END CASE WHEN {nextapprover.id}={user.id} OR {USERROLE} IN {custbody_next_approver_roles.id} THEN 1 ELSE 0 END The first one does not error out but yield incorrect results. For example, the userrole is 3 and the next approvers’ roles are (1035, 1038). It returns TRUE because 3 is included in 10*3*5 and 10*3*8.
d
when you log out
custbody_next_approver_roles.id
is it a csv with no spaces? If so, you can use something like:
','||{custbody_next_approver_roles.id}||',' LIKE '%,'||{USERROLE}||',%'
think you could also reliably use regex if that's your thing
REGEXP_INSTR({custbody_next_approver_roles.id}, '\b'||{userrole}||'\b') > O
l
yes, that field is a CSV with no spaces (it’s a multi-select field). I’ll try that now. Thanks.
d
using your example, that first option would search for
,3,
in
,1035,1038,
(and be false) If role 3 was at the start/end of the multiselect csv list, it would match because you add the delimiter to the start/end of the multiselect csv. i.e.:
,1035,1038,3,
m
What if role 3 is first or last in the list?
l
Works like a charm. Thank you so much!
👍 1