function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Madhu DkMadhu Dk 

when accesing Flow Loop variable getting this errot: Formula result is data type (Object), incompatible with expected data type (Text)

Hi All,

i am working on Service Appointment History
i am fetching the record based on service appointment Id, Field is equal to Status, order by created date desc using Get Records.
next calling the loop
for every itteration i am checking a condition
if(loopvariable.NewValue=='InProgress'){
}

when i run this check it gives error 

Error element ttttt (FlowDecision).
Formula result is data type (Object), incompatible with expected data type (Text).

1. GetRecords
Get SAH REcord
2. Loop
Loop
3. Decision
Decision

 
AnudeepAnudeep (Salesforce Developers) 
Hi Madhu, 

I have seen such errors in the past. The error is very self-explanatory that the data type of NewValue and OldValue is Object and we are trying to perform TEXT operations on it. So ideally we should convert it into TEXT before using it in the display area or comparing with other text in decision elements.

NewValue is of type "AnyType", this field can hold the new value of any salesforce field type.

If a fast lookup is done on the object and stored in SObject collection variable - each SObject variable is looped through the decision and the decision compares Sobject. AnyType equals TextVaribale - that's the reason this error is rightfully thrown since two different data types cannot be compared.

For this to work, the object has to be retrieved via RecordLookup and the newvalue has to be stored in a text variable

Anudeep
Madhu DkMadhu Dk
Hi Anudeep,

Can you pls let me know how to retrieve via RecordLookup.
Right now i am doing get record on service appointment history and storing the details in a variable.

Thank you
AnudeepAnudeep (Salesforce Developers) 
Hi Madhu, 

I don't remember exactly how it is done but guess you need to add a record lookup element, create a text variable and assign the values of fields in the returned record to variables in the flow

See below references

[1] Adding and Configuring a Record Lookup Element
[2] Create the Flow and Add Variables

Anudeep
Scott LandesScott Landes

Hi Anudeep,

I'm actually running into the same issue and Salesforce doesn't seem to allow you to assign these to a text variable. When using an Assignment component and try to assign the field on the record to a text variable, it gives you the same error "Formula result is data type (Object), incompatible with expected data type (Text)". I also attempted to create a simple text formula that is pulls in the field, but my text variable comes back as null.

 

Any help would greatly be appreciated!

Jack Saxe-StaralJack Saxe-Staral
Has anyone been able to successfully view/filter/use NewValue or OldValue from a history object in Flow? I can retrieve records as long as I don't try to filter by NewvalString, OldvalString or NewvalNumber, OldvalNumber (that will gives me the "unable to parse field as dataType could not be retrieved for the passed field:" error).

Once the records are retrieved and stored in a collection I can loop through them but attempting to assign any of the newval/oldval fields to a new text variable fails with an error "No such column 'NewvalString' on entity".

Also, the fields NewValue and OldValue become available for selection in flow elements if referencing a retrieved record (i.e. current record in loop), but trying to use them in a decision element or assignment element just causes the Flow to fail without an error. When debugging it just shows the "thinking" spinner indefinitely.

Any help or direction would be greatly appreciated.
Huy 13Huy 13
Not sure if you guys still need it, but i found a way
First create a Variable(type Text) and assign the oldValue, then create a formula(you choose the type you want) and convert it using the formula, here I want number so my formula is 
VALUE({!NewValTxt})

Then you can assign it into the field you want, I cannot add image so that just it.
Jennifer Carneiro 5Jennifer Carneiro 5
I tried the above Huy 13, and it works in debut but not when you actually schedule the flow :( 
Is this actually working for you?