0

I have created a lightning flow and embeded it with the Lightning component. I am getting an error while invoking the flow from the lightning component.

Lightning Component

<aura:component implements="force:appHostable,flexipage:availableForAllPageTypes,flexipage:availableForRecordHome,force:hasRecordId,force:lightningQuickAction" access="global" controller="AB_AmendOppCntrl">
        <aura:attribute name="objOpportunity" type="Opportunity"/>
        <aura:attribute name="objOppId" type="Id"/>
        <aura:attribute name="recordId" type="Id" access="global"/>
        <!--force:recordData aura:id="opportunityRecord" recordId="{!v.recordId}" fields="AB_Select_the_Amendment"
                          targetRecord="{!v.objOpportunity}" /-->
        <aura:handler name="init" value="{!this}" action="{!c.init}" />
        <lightning:flow aura:id="flowData"/>
    </aura:component>

Controller.js

({
    init : function (component) {
        var action = component.get("c.fetchRecord");
        action.setParams({
            'recId': component.get("v.recordId")
        });
        action.setCallback(this, function(response) {
            var state = response.getState();
            if (state === "SUCCESS") {
                var storeResponse = response.getReturnValue();
                console.log('storeResponse===>',storeResponse);
                component.set("v.recordId",storeResponse.id);
                // Find the component whose aura:id is "flowData"
                if(storeResponse.StageName == "Closed Won"){
                    var flow = component.find("flowData");
                    var inputVariables = [
                        {
                            name : "recordId",
                            type : "SObject",
                            value : { 
                                "Id" : component.get("v.recordId"),
                            }
                            //value : component.get("v.recordId")
                        }
                    ];
                    console.log('inputVariables=====>',inputVariables);
                    // In that component, start your flow. Reference the flow's Unique Name.
                    flow.startFlow("AB_Select_the_Amendment", inputVariables );


                }else{
                    var toastEvent = $A.get("e.force:showToast");
                    toastEvent.setParams({
                        "title":"Error",
                        "message":"Opportunity is not in closed won stage."
                        //"type":"error"
                    });
                    toastEvent.fire()
                }
            }

        });

        $A.enqueueAction(action);
    },

})

In flow I have created the variable called "recordId" as "text" data type and as a input variable.

Please see the following image of the recordId enter image description here

So my question is like what should be the data type of the recordId in controller.js. I have tried with the String but i am getting an error as

We can't launch this flow because of a variable error. Send this error message to your admin. The value {} is being provided for variable recordId but isn't compatible with the variable's data type (String). Check the places where you implemented the flow ‒ such as through a Lightning page or a custom button ‒ and make sure that all provided values are compatible with the variables' data types.

0

Can you please Replace

<aura:attribute name="recordId" type="Id" access="global"/>

With

<aura:attribute name="recordId" type="String" access="global"/>
|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.