1

I am using lightning:recordEditForm and listing the various field I need to create in lightning:inputField. Two of these are dependent picklists, meaning only if the parent picklist has been selected the child will get enabled with associated values. Here is the code;

<lightning:recordEditForm aura:id="contactCreateForm" objectApiName="Contact" recordTypeId="{!v.individualRecordTypeId}"
                        onsubmit="{!c.onSubmit}"
                        onload="{!c.onLoad}"
                        onsuccess="{!c.onSuccess}"
                        onerror="{!c.onError}"
                        >
                            <lightning:messages />
                            <lightning:inputField aura:id="ccf_FirstName" fieldName="FirstName" />
                            <lightning:inputField aura:id="ccf_LastName" fieldName="LastName" />

                            <lightning:inputField aura:id="ccf_nickname" fieldName="Nickname__c" />
                            <lightning:inputField aura:id="ccf_email" fieldName="Email" />

                            <lightning:inputField aura:id="ccf_ReportsToId" fieldName="ReportsToId" />
                            <lightning:inputField aura:id="ccf_Firm_Description__c" fieldName="Firm_Description__c" />
                            <lightning:inputField aura:id="ccf_Userclass__c" fieldName="Userclass__c" />
                            <div align="center">
                                <lightning:button class="slds-m-top_small" variant="brand" type="submit" label="Save" />
                                <lightning:button class="slds-m-top_small" variant="neutral" label="Cancel" onclick="{!c.handleCancel}" />
                            </div>
                        </lightning:recordEditForm

I am setting the value of the parent picklist in the onLoad() event of the lightning:recordEditForm. This gets populated in the UI as expected, however, on the population of parent picklist, I expect the child picklist to get enabled which does not happen.

 onLoad: function(component, event, helper){
   component.find("ccf_Firm_Description__c").set("v.value", component.get("v.accountObj.Location_Firm_Description__c"));
   component.find("ccf_Userclass__c").set("v.disabled",false);
 }

I want to make the child picklist enabled. I tried to set the v.disabled property of the lightning:inputField to false. This throws an internal error.

Error:

Uncaught render threw an error in 'lightning:inputField' [Cannot read property 'config' of undefined] 
throws at https://factset--devpro.lightning.force.com/auraFW/javascript/fm7mXFzeJAXPkqJAjx6Qpw/aura_proddebug.js:24283

I tried doing a $A.get('e.force:refreshView').fire(); on afterRender in the renderer. Doesn't work either. Using jQuery to enable it won't work either because of the locker service and disabling it for my org is not an option. I wanted to know if I'm missing something before raising a case with Salesforce.

Any help on how to enable the dependant picklist is much appreciated.

2
  • did you get any idea to make this work ? i am stuck with same issue :'( Commented Feb 8, 2018 at 14:30
  • @RaviNarayanan, I would suggest creating a case with Salesforce. We are planning to do the same. More case, more traction the issue will get and eventually they'll fix it.
    – GdnMaximus
    Commented Feb 8, 2018 at 15:34

1 Answer 1

3

Sorry if my previous explanation wasn't clear. If we are going to set the value of master picklist using controllerJS, then it is recommended to rerender the dependant picklist for changing the dependant values.

i did this and it works !!

i set the value of refreshFlag to False before setting the master picklist field value and once it is done again i changed the boolean refreshFlag to True. THis rerender the dependant picklist component and the correct values gets reflected.

<!-- dependeant picklist goes here -->
<aura:if isTrue="{!v.refreshFag}">
  <lightning:inputField fieldname="dependantpicklist__c"/> 
</aura:if>
8
  • eventhough you are answering your own question, mind adding a bit of context, an explanation and the working code snippet? thanks
    – glls
    Commented Feb 10, 2018 at 14:49
  • Sorry about that. i edited my answer and hope it makes some sense now. Thanks for your comment . Commented Feb 12, 2018 at 17:06
  • the above solution does not work in mozilla :( Commented Feb 19, 2018 at 12:34
  • @RaviNarayanan, on which method are you setting the refreshFlag to true? I tried it on onLoad event of the recordEditForm where I set the master picklist and it did not work. I tested this on chrome browser.
    – GdnMaximus
    Commented Feb 20, 2018 at 19:54
  • If you are going to set the master picklist in controller init, you don’t need refresh flag . However if you are more specific about using record edit form on load , then refresh flag should work . If you don’t mind could you please post your code . I can check and try to help you Commented Feb 22, 2018 at 18:43

You must log in to answer this question.

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