Appian Community
Site
Search
Sign In/Register
Site
Search
User
DISCUSS
LEARN
SUCCESS
SUPPORT
Documentation
AppMarket
More
Cancel
I'm looking for ...
State
Not Answered
Replies
11 replies
Subscribers
10 subscribers
Views
5015 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
Data and Records
Hi, I have a record type in which I have set the filters to view the record
chandhinir
over 10 years ago
Hi,
I have a record type in which I have set the filters to view the record based on the logged In User using "in" operator . If there are no records for the user, I am getting the error as "cannot apply "in" operator to the record field".
Please provide suggestions....
OriginalPostID-113124
OriginalPostID-113124
Discussion posts and replies are publicly visible
0
sumitp584
over 10 years ago
Why dont you check for null condition first then if its not null do your apply fn
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Michael Tan
Appian Employee
over 10 years ago
What is your expression? I have achieved something similar with this expression:
Record Field: viewerGroupID
Operator: in
Value: ={tointeger(getgroupsoftypeforuser(loggedInUser(), "MMS Viewer Groups"))}
ViewerGroupID is an integer field in the database which is the groupID in the system. The expression constructs a list of group IDs of the group type for the logged in user. Be careful when filtering in this fashion, it works for filtering based on who is viewing data, but not actually securing the data.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
chandhinir
over 10 years ago
Hi Michael,
Please find the scenario below:
There will be three roles as Executive , Senior Manager and Supervisor.All the three roles can able to create the workflows.If Executive is logged in,the record has to list all the workflows which was created by three roles.If Senior Manager is logged In,only the workflows which belongs to his region has to be displayed . If Supervisor is logged in, then only his workflows has to be displayed in the records.
Suppose if the Supervisor does not create any workflows, then the result will be empty. In this case, the "in" operator throws an error.
My Expression will be like this:
Record Field: workflowID
Operator in
value: rule!displayWorkflowsbasedOnRole(loggedinUser())
Thanks,
Chandhini R
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Michael Tan
Appian Employee
over 10 years ago
What is the underlying expression behind displayWorkflowsbasedOnRole?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
chandhinir
over 10 years ago
with(
userProfileID:rule!GWF_getUserProfSKByLanId(ri!owner).gwfUsrPrfSk,
userRoleID:if(rule!APN_isBlank(userProfileID),null(),rule!GWF_getUserPrivIdByProfId(local!userProfileID,cons!GWF_ACTIVE_FLAG_VALUE).gwfUsrRoleId),
execRole:if(rule!APN_isEmpty(userRoleID),false(),contains(local!userRoleID,cons!GWF_EXECUTIVE_ROLE_ID)),
smRole:if(rule!APN_isEmpty(userRoleID),false(),contains(local!userRoleID,cons!GWF_SENIOR_MANAGER_ROLE_ID)),
supervisorRole:if(rule!APN_isEmpty(userRoleID),false(),contains(local!userRoleID,cons!GWF_SUPERVISOR_ROLE_ID)),
owners:if(local!execRole,rule!GWF_ExecutiveGroupForActiveWorkflows(local!userRoleID),
if(local!smRole,rule!GWF_SeniorManagerGroupForActiveWorkflows(userRoleID,userProfileID),
if(local!supervisorRole,rule!GWF_SupervisorGroupForWorkflows(userRoleID,ri!owner),null()))),owners)
GWF_ExecutiveGroupForActiveWorkflows:
if(contains(ri!roleID,cons!GWF_EXECUTIVE_ROLE_ID),rule!GWF_getAllWFModelsByTypeAndActiveFlg(upper(cons!GWF_TYPE_WORKFLOW),cons!GWF_ACTIVE_FLAG_VALUE).gwfWfSk,null())
GWF_SeniorManagerGroupForActiveWorkflow:
if(contains(ri!userRoleID,cons!GWF_SENIOR_MANAGER_ROLE_ID),
with(
regionIDs:rule!GWF_getPrivilegeDataByProfileIDAndRoleID(ri!userProfileID,cons!GWF_SENIOR_MANAGER_ROLE_ID ,cons!GWF_ACTIVE_FLAG_VALUE).gwfUsrPrivId,
regionLabels:if(rule!APN_isEmpty(local!regionIDs),null(),rule!GWF_getRefLookupDataByRefLookupID(local!regionIDs).gwfRefLkupShortDesc),
wfIDs:if(rule!APN_isEmpty(local!regionLabels),null(),rule!GWF_getMetadataByTypeAndValue(upper(cons!GWF_TYPE_WORKFLOW),local!regionLabels,cons!GWF_ACTIVE_FLAG_VALUE).gwfWfId),
SMWorkflows:if(rule!APN_isEmpty(local!wfIDs),null(),rule!GWF_getWFModelsDataByWFID(local!wfIDs,cons!GWF_ACTIVE_FLAG_VALUE).gwfWfSk),
SMWorkflows),null())
rule!GWF_SupervisorGroupForWorkflows:
if(contains(ri!roleID,cons!GWF_SUPERVISOR_ROLE_ID),rule!GWF_getWorkflowsByWfTypeAndOwner(upper(cons!GWF_TYPE_WORKFLOW),ri!owner,cons!GWF_ACTIVE_FLAG_VALUE).gwfWfSk,null())
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Michael Tan
Appian Employee
over 10 years ago
In your rule, can you test setting the expression to return an empty array {} for the scenarios that should result in null. The operator is incompatible when you are outputting null() (which is a single value vs. an array).
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
chandhinir
over 10 years ago
I have already tried {} but still I am getting the error as "Cannot apply operator [IN] to field [gwfWfSk] when comparing to value [TypedValue[it=3,v=]]. (APNX-1-4203-015) "
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Michael Tan
Appian Employee
over 10 years ago
Thanks for testing that. I misread the problem initially. Can you confirm that the issue is occurring under the scenario that this expression evaluates to true:
contains(ri!roleID,cons!GWF_SUPERVISOR_ROLE_ID)
but the following expression does not yield any results:
rule!GWF_getWorkflowsByWfTypeAndOwner(upper(cons!GWF_TYPE_WORKFLOW),ri!owner,cons!GWF_ACTIVE_FLAG_VALUE).gwfWfSk
Essentially, you need to make sure that your local owners variable is still initialized as an array of the same type your record field, workflowID.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
chandhinir
over 10 years ago
rule!GWF_getWorkflowsByWfTypeAndOwner(upper(cons!GWF_TYPE_WORKFLOW),ri!owner,cons!GWF_ACTIVE_FLAG_VALUE).gwfWfSk--->returns empty result.
I modified the main rule "displayWorkflowsbasedOnRole" to check null condition for all the workflows.Now my expression rule will be:
with(
userProfileID:rule!GWF_getUserProfSKByLanId(ri!owner).gwfUsrPrfSk,
userRoleID:if(rule!APN_isBlank(userProfileID),{},rule!GWF_getUserPrivIdByProfId(local!userProfileID,cons!GWF_ACTIVE_FLAG_VALUE).gwfUsrRoleId),
execRole:if(rule!APN_isEmpty(userRoleID),false(),contains(local!userRoleID,cons!GWF_EXECUTIVE_ROLE_ID)),
smRole:if(rule!APN_isEmpty(userRoleID),false(),contains(local!userRoleID,cons!GWF_SENIOR_MANAGER_ROLE_ID)),
supervisorRole:if(rule!APN_isEmpty(userRoleID),false(),contains(local!userRoleID,cons!GWF_SUPERVISOR_ROLE_ID)),
execWF:rule!GWF_ExecutiveGroupForActiveWorkflows(local!userRoleID),
smWF:rule!GWF_SeniorManagerGroupForActiveWorkflows(userRoleID,userProfileID),
supervisorWF:rule!GWF_SupervisorGroupForWorkflows(userRoleID,ri!owner),
workflowIDs:if(local!execRole,if(rule!APN_isEmpty(execWF),{},local!execWF),
if(local!smRole,if(rule!APN_isEmpty(smWF),{},local!smWF),
if(local!supervisorRole,if(rule!APN_isEmpty(supervisorWF),{},local!supervisorWF),{-1}))),workflowIDs)
Now it is working fine.Thanks!!
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Michael Tan
Appian Employee
over 10 years ago
Glad you got it working!
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
>