...I have tried EVERYTHING and cant seem to find what I am doing wrong. I am trying to prepopulate ParentWorkOrder on a new workorder lightning record create here is my code. I am new to writing components so please help.

<aura:component access="global">

    <aura:attribute name="recordId" type="String"/>
    <aura:attribute name="parentId" type="String" default="0WO54000000D0zw"/>
    <aura:attribute name="ONOFF" type="string" default="false"/>

    <lightning:recordEditForm aura:id="recordEditForm"
        <lightning:messages />
        <lightning:inputField fieldName="Service_Filters_Needed__c" />
        <lightning:inputField fieldName="Is_there_an_issue_with_equipment__c" />
        <lightning:outputField fieldName="ParentWorkOrder" aura:id="parentWOLookup" value=""/>
        <lightning:button class="slds-m-top_small" type="submit" label="submit" />



    handleSuccess : function(component, event, helper) {
        var payload = event.getParams().response;
        component.set("v.ONOFF", true);     

    handleOnSubmit : function(component, event, helper) {
      var fields = event.getParam("fields");
      fields["ParentWorkOrder"] = component.get("v.parentId");
  • 1
    Please give your questions a clear, descriptive title. "PLEASE HELP ME" in all caps does not help guide the relevant expertise to your question.
    – David Reed
    Feb 7 '19 at 21:16
  • it would be user error on my part, gotr it working now Feb 7 '19 at 23:23

I haven't really tried it out, but based on what is mentioned in the documentation for lightning:recordEditForm:

If you capture the submit event and submit the form programmatically, use event.preventDefault() to cancel the default behavior of the event.

You will need to modify your handleOnSubmit JS function to something as below. You can refer more on the example as in the documentation on these behaviors.

handleOnSubmit : function(component, event, helper) {
    // add this in your function to stop submitting the form

    var fields = event.getParam("fields");

    // notice how ParentWorkOrder field is being referred
    fields.ParentWorkOrder = component.get("v.parentId"); 

    // submit the form now

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.