+ Start a Discussion
James Gauci 7James Gauci 7 

Redirect to created entity after creation flow

Hi all, I have a problem regarding Apex Code in flows. I have this flow that's sole purpose is to create an entity (Notice in this case) using the variables passed to it. Up to the creation of the entity, the flow works perfectly.

However now we require the system to redirect to the created entity at the end of the flow. After having done some research on the subject, we created a lightning resource in order to do this functionalty. Below is the code of this lightning resource:

Component Part:
<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,lightning:availableForFlowActions,lightning:availableForFlowScreens">
	<aura:attribute name="recId" type="String" />
</aura:component>
Controller Part:
({
    invoke : function(component, event, helper){
        console.log(component.get( "v.recId" ))
        $A.get( "e.force:navigateToSObject" ).setParams( {
            "recordId": "a021j000002DBCNAA4",
            "slideDevName": "related"
        } ).fire();
        
    }
})

Design Part:
<design:component>
    <design:attribute name="recId" label="Id of the record" />
</design:component>
 We left the remaining components as default or empty. Following this code, which should take the ID of the created notice and navigate to it, we added an action to this flow that calls this code. The following are images of the flow and action:
Image of full flowImage of action

Primarily we tested the action in the debugger, and the function seemed to work properly, with no errors coming up and the notice being created. Also it seems that the notice ID of the newly created notice is being passed successfully into the flow. However, when the flow was tested in the sandbox directly, a generic error pops up as shown below:
User-added image
Sorry for the Italian, but basically it simply tells me that an error has been found in the flow, and that i need to contact the administrator. Can someone advise on what we could be doing wrong? Thanks.

 
James Gauci 7James Gauci 7
Hi all, I would like to refresh this post since I did not get any feedback and still need help regarding this issue. Thanks.