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
8 replies
Subscribers
10 subscribers
Views
2571 views
Users
0 members are here
Share
More
Cancel
Related Discussions
Home
»
Discussions
»
Data and Records
At a record level for the related action, is there a way to capture who is actua
mjmallet
over 9 years ago
At a record level for the related action, is there a way to capture who is actually logged in?
I tried the loggedinuser() doesn't seem to work. I want to see if the person that is logged in is the creator of the record, if they are then show them the related action.
OriginalPostID-187835
OriginalPostID-187835
Discussion posts and replies are publicly visible
0
sikhivahans
over 9 years ago
@mjmallet To the best of my knowledge, that's very much possible and loggedInUser() works. But it would be grateful if you could let us know what or how you have done so that the Appian practitioners here could make their valuable suggestions if there is a mistake in your implementation.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
PhilB
A Score Level 1
over 9 years ago
loggedinuser() is the right one to use. When you say it didn't work, what was the issue?
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
Tim
Certified Lead Developer
over 9 years ago
Try loggedInUser()
forum.appian.com/.../Scripting_Functions.html
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
mjmallet
over 9 years ago
here is the expression rule I've created
=
load(
local!productInfo : rule!RADARR_QR_PRODUCT_getProductByRADARRID(ri!radarrID),
local!projectInfo : rule!RADARR_QR_PROJECT_getProjectByProjectID(local!productInfo.PROJECT_ID),
local!userLoggedIn: fn!loggedInUser(),
if(
and(local!productInfo.PRODUCT_STATUS = cons!RADARR_CST_productStatus[1],
or(local!projectInfo.PROJECT_STATUS = cons!RADARR_CST_projectStatus[1],local!projectInfo.PROJECT_STATUS = cons!RADARR_CST_projectStatus[2])),true,
if(and(local!productInfo.PRODUCT_STATUS = cons!RADARR_CST_productStatus[1],local!projectInfo.PROJECT_STATUS = cons!RADARR_CST_projectStatus[3],local!productInfo.PRODUCT_CREATOR = local!userLoggedIn),
true,
false
)
)
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
PhilB
A Score Level 1
over 9 years ago
I'm assuming this rule is called in the visibility for the related action with rp!id as an input? I believe it can be simplified - see below, maybe even moreso than that - but it might also be worth wrapping the calls to get the products in an index function so that they only return single items rather than an array of a single item.
In addition, have you tried debugging this rule by hardcoding the loggedInUser() and product to specific values to check it actually works?
=load(
local!productInfo : rule!RADARR_QR_PRODUCT_getProductByRADARRID(
ri!radarrID
),
local!projectInfo : rule!RADARR_QR_PROJECT_getProjectByProjectID(
local!productInfo.PROJECT_ID
),
if(
and(
local!productInfo.PRODUCT_STATUS = cons!RADARR_CST_productStatus[1],
or(
local!projectInfo.PROJECT_STATUS = cons!RADARR_CST_projectStatus[1],
local!projectInfo.PROJECT_STATUS = cons!RADARR_CST_projectStatus[2]
)
),
true,
and(
local!productInfo.PRODUCT_STATUS = cons!RADARR_CST_productStatus[1],
local!projectInfo.PROJECT_STATUS = cons!RADARR_CST_projectStatus[3],
local!productInfo.PRODUCT_CREATOR = fn!loggedInUser()
)
)
)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
mjmallet
over 9 years ago
Thanks Phil, it's working by using local!productInfo.PRODUCT_CREATOR = fn!loggedInUser() (I will try to simplify the code, I'm still learning SAIL) :)
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sikhivahans
over 9 years ago
@mjmallet To the best of my knowledge, the problem lies with the local!productInfo and local!projectInfo variables.
The problem here is, the local variables has the capacity to accept any type value, and because of this capability, the local variables hold values of type multiple especially when we make queries(also the query rules always return in array mode). For example, local!productInfo could look to us like it carries the result of type single. But what actually happens here is, the local variable carries the results of array type.
Now we might wonder why the problem comes with a variable that carries a results in an array mode. So, when we use these kind of variables in if condition, and function, or function etc, you will experience a weird behaviour which finally leads to such a state that the related action won't work even if you properly write a expression rule that results in true or false.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel
0
sikhivahans
over 9 years ago
These kind of scenarios work properly when we use elsewhere but the related action visibility is especially sensitive. So what you should be doing is, it's better to cast the results so that they hold single type or use index function.
That is, what you should be doing is
local!projectInfo: cast(typeof(type!projectInfo()),rule!getProject()),
or use index() as suggested by Phil.
This hasn't been specified in Appian documentation but this is a common problem I have seen in many implementations and it would be good to code keeping the above in mind.
Cancel
Vote Up
0
Vote Down
Sign in to reply
Verify Answer
Cancel