0

In a Flow I have a Decision Element with condition logic like so:

Opportunity.Date_Field__c     is null      GlobalConstant.TRUE
Opportunity.Date_Field__c   greater than   Custom_Object__c.DateField__c

with "One condition must be true (OR)"

I would expect that this would short-circuit after the first condition but I'm getting this error when my Flow runs:

The flow failed to access the value for Opportunity.Date_Field__c because it hasn't been set or assigned.

Do I need to separate this logic or is this a bug?


So I changed my Decision Element to have the first condition be in one outcome, and the second condition in a second outcome and I'm still getting the error.

After checking my logs, the Opportunity is getting assigned, but the Date_Field__c doesn't seem to show up.

{
 AccountId=0011800000QaheKAAR
 CloseDate=2016-05-01 00:00:00
 ContactId=0031800000LZHYjAAP
 CreatedById=005C0000008cyo4IAA
 CreatedDate=2016-08-16 14:05:27
 ForecastCategory=Forecast
 ForecastCategoryName=Commit
 HasOpenActivity=false
 HasOpportunityLineItem=false
 HasOverdueTask=false
 Id=00618000004L1yzAAC
 IsClosed=false
 IsDeleted=false
 IsPrivate=false
 IsWon=false
 LastModifiedById=005C0000008cyo4IAA
 LastModifiedDate=2016-09-30 13:10:11
 LastStageChangeDate=2016-09-30 13:10:11
 Name=Test1 - 2016-07-15
 OwnerId=00580000003Xfe9AAC
 Probability=100
 RecordTypeId=012180000008id2AAA
 StageName=Established
 StageSortOrder=19
 SystemModstamp=2016-09-30 13:10:11
}
5
  • How are you retrieving the opportunity data - is it into an sObject?
    – Dave Humm
    Commented Sep 30, 2016 at 14:30
  • The Flow is an auto-launched flow. Opportunity is an sObject variable and it is being assigned from a Process Builder process.
    – dBeltowski
    Commented Sep 30, 2016 at 14:34
  • 1
    Check that the sObject and the calling Process Builder reference Date_Field__c as it needs to be explicitly included in the sObject to be available in the flow.
    – Dave Humm
    Commented Sep 30, 2016 at 14:39
  • @DaveHumm so in my Flow I reference it with the Decision Element and an Assignment element {!Opportunity.Date_Field__c}. Is this not enough, what would be the best way to reference it?
    – dBeltowski
    Commented Sep 30, 2016 at 14:51
  • I'll do a proper answer.
    – Dave Humm
    Commented Sep 30, 2016 at 14:55

3 Answers 3

2

This is probably caused by not retrieving the value of the Opportunity.Date_Field__c into the sObject variable. With a headless flow being called by Process Builder you can call the flow and pass in the Opportunity Id as a parameter then call use a fast lookup to retrieve the opportunity fields into an sObject.

When the sObject is created any fields that you will reference in the flow will need to be explicitly selected to be available. So in my image below for a custom property object I am using the Id and other fields that are explicitly retrieved.

If I tried to use any fields from the sObject that had not been included in this list it will produce the error you have found of:

The flow failed to access the value for Opportunity.Date_Field__c because it hasn't been set or assigned.

In the decision element it would need to be assessing the value as sObject.field, e.g. sovOpportuity.Date_Field__c.

enter image description here

4
  • Technically I'm not using a Lookup to get the Opportunity. I'm passing it in from a Process Builder process. That being said I can see how Salesforce would do this on the backend the way you described. I will switch my Flow to use a Lookup and declare all the relevant fields.
    – dBeltowski
    Commented Sep 30, 2016 at 15:12
  • I'm not sure that it would get all the values that way. What fields are you passing from the process builder to the flow for the opportunity?
    – Dave Humm
    Commented Sep 30, 2016 at 15:15
  • I'm not passing any fields. I'm directly passing the Opportunity and assigning it to an sObject Variable.
    – dBeltowski
    Commented Sep 30, 2016 at 15:18
  • I would normally pass the opportunity id into a variable varOppId then use that in the sObject fast lookup.
    – Dave Humm
    Commented Sep 30, 2016 at 15:20
1

Did some digging on this instead of me just guessing and posting wrong answers. :D

https://help.salesforce.com/apex/HTViewSolution?id=000212174&language=en_US

It seems as though the Opportunity value is null, it cannot get Date_Field__c.

1
  • 2
    You made me doubt myself so I checked the logs and this is not the case. The record I am testing on shows the Opportunity being assigned with values. However interestingly enough my Date_Field__c does not show up as a value. I'm going to update my question.
    – dBeltowski
    Commented Sep 30, 2016 at 14:25
1

So with Dave Humm's help I was able to get my Flow working by using a Fast Lookup to get the Opportunity and the Fields I required.

While this did work and solved my issue I wasn't fully satisfied as I figured I shouldn't have to do a Lookup when I'm passing in the Opportunity.

I ended up revisiting my Flow and figured out a way to do it without the Fast Lookup. So I'm posting my final solution as the answer.

What I ended up doing was using the "was set" operator in the Decision Element.

Opportunity.Date_Field__c     was set      GlobalConstant.FALSE
Opportunity.Date_Field__c     is null      GlobalConstant.TRUE
Opportunity.Date_Field__c   greater than   Custom_Object__c.DateField__c

with "One condition must be true (OR)"

When this evaluated to TRUE, I would populate my Opportunity.Date_Field__c and all was good.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .