At a record level for the related action, is there a way to capture who is actua

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

  • @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.
  • loggedinuser() is the right one to use. When you say it didn't work, what was the issue?
  • 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
    )
    )
    )
  • 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()
    )
    )
    )
  • 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) :)
  • @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.
  • 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.