2

I need to prepopulate fields in lightning:recordEditForm and then get their values to save using Apex (without submitting form itself). What I've already tried:

  1. When I setting

    <lightning:inputField value="{!v.contact.MailingAddress} fieldName="MailingAddress"/>
    

It's prepopulated, but I can't access updated values afterwards. Stringified component.find("mAddress").get("v.value") showing nulls everywhere.

  1. When trying onload

    let address = component.find("mAddress").get("v.value");
    address["MailingCountryCode"] = "US";
    component.find("mAddress").set("v.value", address);
    

Not prepopulating. But can access updated field value with component.find("mAddress").get("v.value").MailingCountryCode. Same if trying to set after loaded, even on button click.

  1. Find fields directly with querySelector - don't have access, maybe since it's on Partner Portal Community. By id - for compound Address each field id generated by Lightning, so I'm not sure if I can use them.
  2. Set up aura:attribute with type Address, ConnectedApi.Address, Object - also seems not working.

Is there some other way/option to prepopulate MailingAddress and get updated value on button click?

1

It seems that for now we don't have any way to directly populate lightning:inputField with compound Address fields. It contains some internal object, which can't be setted. Maybe it has some methods to set/get, but without documentation it's hard to even guess. So for the moment it seems that if we can't use retrieving record by lightning:recordEditForm - we need to make a custom dependent picklist.

Solution which worked for me - https://salesforcespace.blogspot.com/2018/08/salesforce-lightning-dependent-picklist.html

If someone would find better solution - feel free to wrote it here, I would change an Accepted 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.