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
goravsethgoravseth 

Fault handling when flow is embedded in visualforce page

Finally have fault handling setup in my flow, and its working perfectly well when I launch the flow from the "run" button on the flow itself.  The fault handling process runs a subflow to create a case and displays a friendly error message to the user, all good.

In production, however, the flow is embedded into a visualforce page (to get some better flow finish behvaior) and in this case, when a fault triggers, a generic fault message appears on the screen, and my subflow is not triggered.

ERROR MESSAGE:
An unhandled fault has occurred in this flow
An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information.

So, my question is:  For a flow embedded on a VF page, do I need to manage exception handling via the custom controller?  In which case, is it possible to still trigger the subflow?  Or do I have to choose between flow finish behavior and declarative fault handling?

Thanks!
Best Answer chosen by goravseth
Ashish_SFDCAshish_SFDC
Hi Gorav, 


Found this on a blag below, 

* Error handling is harder to handle in a flow. There are items called Faults that need to be built into a Flow.  They will catch exceptions and help you to route to the correct page, but a system generated error is still sent out by email when these happen.

http://www.sundoginteractive.com/sunblog/posts/to-flow-or-to-visualforce-that-is-the-question

There has to be further troubleshooting done to check where exactly the error is unhandled which possible could be an element wthout a fault connector. 

We need to see the debug logs to check at which point the exception is being thrown in the Visualforce page. 

Kindly open a support case for further investigation. 


Regards,
Ashish

All Answers

Ashish_SFDCAshish_SFDC
Hi , 


You can handle the exeption in a controler. 

Did you set up as per the instructions, 

http://help.salesforce.com/HTViewHelpDoc?id=vpm_admin_add_flow_to_vfpage.htm&language=en_US


Regards,
Ashish
goravsethgoravseth
Thank you Ashish,

Yes, set it up as in the help doc, but am using a custom controller to feed in a variable from the flow to the page and display some contact details on some flow pages.  If you can point me at any add'l info on error handling for flows in the controller, that would be much appreciated.

 The VF page:
<apex:page controller="quickCreateContactController">

    <flow:interview name="Quick_Create_Contact" interview="{!quickCreateFlow}" finishLocation="{!URLFOR('/003/o')}">
    <style type="text/css">
    input.btn[name="del"] {           
        display: none;
    }
    input.btn[name="clone"] {
        display: none;
    }
    input.btn[name="edit"] {
        display: none;
    }
    input.btn[name="share"] {
        display: none;
    }
    </style>
    <apex:detail subject="{!myId}" relatedList="false"/>
   
    </flow:interview>
   
</apex:page>

The controller:
public class quickCreateContactController {

    public String myNewId { get; set; }
    public Flow.Interview.Quick_Create_Contact quickCreateFlow { get; set; }
   
    public String getMyID() {
       
        if (quickCreateFlow == NULL)
            return '';
        else
            if (quickCreateFlow.vaShowThisContactId != NULL)
                return quickCreateFlow.vaShowThisContactId;
            else
                myNewId = quickCreateFlow.vaNewCreatedContactId;
                return myNewId;
   }
}
Ashish_SFDCAshish_SFDC
Hi , 


Need some more information on this, 

What is returned to the VF page? 

Where is the DML (Insert) operation carried?

Is the both If and Else block throwing the same error?

There is a return ' ' - how is that significant for the flow set?


See the below thread with similar error,

"Looks like you are creating a record in salesforce, but are passing a null value when the database expects a not-null value."

https://developer.salesforce.com/forums/ForumsMain?id=906F00000009AdiIAE

Also see a related discussion.

http://salesforce.stackexchange.com/questions/16595/error-message-on-flow-embedded-in-visualforce-page


Regards,
Ashish
goravsethgoravseth
Thanks again Ashish,

I'm not currently encountering any error w/ the flow.   I'm simply trying to get the standard exception handling mechanism that is built into flows to work properly, in case a user encounters an error in the future.

The flow's fault handling mechanism works fine within the flow.

In production, however, the flow is embedded into a visualforce page, and the fault handling does not work.

The VF page simply displays some contact details during a step in the flow and provides for some flow finish behavior.

Only the contact ID is passed between the flow and the page.   Again, I'm not encountering an error running the flow - the issue is that the fault handling mechanism does not work when the flow is embedded on a visualforce page, though it works fine when the flow is run outside of the vf page (I have set the flow in a way that I can intentionally trigger a fault for testing)

Is that clear?  
Ashish_SFDCAshish_SFDC
Hi , 


Please make sure the "Input/Output Type" of variables  "vaShowThisContactId" & "vaNewCreatedContactId" in the flow are set to "Input and Output" so that they can be passed from the controller to the Flow and vice versa.

To do this, open the flow and go to "Explorer" tab.

Double click on the variable and change the Input/Output Type.

Click OK and save the flow.

Try now in VF Page.


Regards,
Ashish

Ashish_SFDCAshish_SFDC
Hi Gorav, 


Found this on a blag below, 

* Error handling is harder to handle in a flow. There are items called Faults that need to be built into a Flow.  They will catch exceptions and help you to route to the correct page, but a system generated error is still sent out by email when these happen.

http://www.sundoginteractive.com/sunblog/posts/to-flow-or-to-visualforce-that-is-the-question

There has to be further troubleshooting done to check where exactly the error is unhandled which possible could be an element wthout a fault connector. 

We need to see the debug logs to check at which point the exception is being thrown in the Visualforce page. 

Kindly open a support case for further investigation. 


Regards,
Ashish
This was selected as the best answer
goravsethgoravseth
Thanks Ashish,

Your help has been greatly appreciated.  You are correct - one error did not have a fault connector, and thus the VF page was not doing what I thought it would.  Once the fault connectors are in place, the VF page displays them appropriately.

Thanks again - really appreciate your efforts!