0

Is it possible to execute a form post to an external site from an aura component that is exposed in a community page?

Our aura component looks like this

<aura:component implements="forceCommunity:availableForAllPageTypes" access="global">
    <aura:handler name="init" value="{!this}" action="{!c.init}" />
    <lightning:flow aura:id="flowData" onstatuschange="{!c.handleStatusChange}" />

    <form name="paymentForm" aura:id="paymentForm" action="https://..." method="POST">
        <input type="hidden" name="ccId" value="123" />
    </form>
</aura:component>

and we'd like to do something like this; set our form variables using the output variables from the flow before submit

handleStatusChange : function (component, event) {
    if(event.getParam("status") === "FINISHED") {
        var outputVariables = event.getParam("outputVariables");
        //set form variable using output variables from flow
        component.find("paymentForm").submit();
    }
 }
1
  • I'm not sure how to do this through a form tag in Lightning Aura Components (do regular form tags even work there?), but you can just use regular inputs and other components to gather the data that you want to send. From there, you can package that data up and send it to a controller class to create an HttpRequest object, select the endpoint, and add the form data in the body. Then send it through an Http object. developer.salesforce.com/docs/atlas.en-us.apexcode.meta/…
    – Roti
    Commented Sep 26, 2019 at 20:06

1 Answer 1

0

Changing the submit to this works:

component.find("paymentForm").getElement().submit();

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .