+ Start a Discussion
ajbtv23ajbtv23 

Flow Variables: Current User information

I am looking to set up flow and was wanting to prepoluate varibales with User.AccountID and User.ContactID  I'm not seeing where I can access user variables in Flow.  Am I missing something?

cmoylecmoyle

ajbtv23-

You can prepopulate variable values directly in the flow url. So lets say you have you a flow with url xxx/flow/main and you want the to populate variable A in your flow. Your url would then look like xxx/flow/main?A=some_value. I'm not entirely certain how well this works with direct flow URL's, I had a <flow> tag on a visualforce page that this worked with. Good Luck!

BenjKBenjK

I'm worried that this approach could be spoofed, especially if trying to check user permissions. A savvy user could figure out how to inject another user's profileID into the URL.  Thoughts?

cmoylecmoyle

If you need validation or security around your variables, it would make more sense to populate them using an Apex Callout. You need to create an Apex class that implements the Process.Plugin interface. 

abhishektandon2abhishektandon2

Please create a extention controller and user apex:param or try to set values which are populatd by constructor of controller

 

<apex:page standardController="Account" extensions="AccountExtention" >

<flow:interview name="LandscapingQuestionnaire" finishLocation="{!EndPage}" interview="{!landscaping_interview}" buttonStyle="btn" >
<apex:param name="accid" assignTo="{!accid}" value="{!account.id}"/>
<apex:param name="accName" assignTo="{!accName}" value="{!accout.Name}"/>

<apex:outputLabel value="{!landscaping_interview.percentagecomplete}"></apex:outputLabel>
</flow:interview>
</apex:page>

Will_SladeWill_Slade

Hi,

 

I tried something similar in our dev environment but using global variables.  I created the matching variables in my flow, and it works correctly until I go to validate a change set containing the flow...  The validation error I get tells me No variable "ContactIdFlow" exists in the flow - when indeed it does.  Here is the code from the VF Page:

 

        <flow:interview name="FEPlacementRequest" finishLocation="{!EndPage}" interview="{!placementInterview}">
            <apex:param id="ContactIdParam" name="ContactIdFlow" value="{!$User.ContactId}"/> 
            <apex:param name="ContactName" value="{!$User.FirstName}"/>                                   
        </flow:interview>
RajaramRajaram

Make sure the active version of the flow has the variable. If no active version is found and you are an admin, the apex page will compile against the most recent deactivated versoin.

 

Will_SladeWill_Slade

Thank you for the reply.  Yes the active version has it... in fact all stored versions have it as well.  I had to work around the issue by commenting those two lines out of my Visualforce page for moving the change set, then changing them back in the new org.  I will do some further testing today to see if I can figure out what's going on.

Heather ThompsonHeather Thompson
There's not exactly a User.ContactID and AccountID the same way there is in Apex, but you can create a current user variable using {!LoginFlow_UserId} to get the current user with a lookup field and save the ContactID field and look up Contacts and Accounts. You can see an example here (https://heathert93.wordpress.com/2015/02/12/using-login-flow-to-dynamically-create-notifications/).