+ Start a Discussion
Craig WoodmanCraig Woodman 

java.lang.ClassCastException error when running a flow

Hi everyone,

I ran into a strange error in a flow. I have a flow that calls a subflow to return a date 7 business days into the future. 

The parent flow then attempts to compare the 7 day date to a date field on the Opportunity object using a decision element. Pretty straight forward. It runs fine with an internal Salesforce user.

When I put this in a community (running the flow in system mode - Access all records) when I get to the comparison element, I get the following error:

java.lang.ClassCastException: class java.lang.String cannot be cast to class moduleapi.interaction.DateOnly (java.lang.String is in module java.base of loader 'bootstrap'; moduleapi.interaction.DateOnly is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @29d37757)

I used debugging to isolate this to the decision element trying to compare the date field passed back in from the 7 day subflow to a date field on the Opportunity object. System mode allows display of the field in a community. I figure this has something to do with an internal class inside of Salesforce not having access to the Sobject date value from the comunity, even when the flow is in system mode.

The 7 day flow runs successfully in another flow within the community, so it is returning the date correctly. 

The flow that calls the subflow, is yet another subflow, that receives the Opportunity information with a passed in sobject variable. 

2 Workarounds for this:

Create a YYYYMMDD value for the date, using a formula field. This allows greater than/less than comparisons using the number.

Peform a seperate lookup, assigning to a traditional date variable. For some reason, the date variables can be compared, and displayed, passed into flows, all within a community.

Has anyone else run into this? Is there a reason for, or a fix for, not being able to access an Sobject date value in a community?
AnudeepAnudeep (Salesforce Developers) 
I recommend raising a support case. This is similar to the error described in the Known Issue although the error is slightly different in that it refers to FlowPicklistValue as opposed to String

"class moduleapi.interaction.FlowPicklistValue cannot be cast to class java.lang.String (moduleapi.interaction.FlowPicklistValue is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @51745f40; java.lang.String is in module java.base of loader 'bootstrap')"

Let me know if this helps. If it does, please mark this answer as Best. It may help others in the community. Thank You!