0

There is a weird scenario I'm facing while I try to bind the markup UI tags with Lightning aura:attribute as type sObject (fields). I'm trying to bind data to sobject's fields for different lightning:input tags, For one sObject attribute the binding works perfect, but in the same way for another sObject the data is not getting bound. For Ex:

<aura:attribute name="student" type="JN_Student__c" access="global" default="{'sobjectType' : 'JN_Student__c'}" />
  <lightning:input aura:id="requiredVal" 
                 name="lastName" 
                 label="Legal Last Name"
                 value="{!v.student.JN_Last_Name__c}"
                 maxlength="20"
                 required="true"/>

This works perfectly and the data persists as I show/hide this section. WHEREAS for,

<aura:attribute name="insuranceInstance" type="JN_Insurance__c" access="global" default="{'sobjectType' : 'JN_Insurance__c'}" />
<lightning:input aura:id="requiredVal" 
                                   name="lastName" 
                                   label="Legal Last Name"
                                   value="{!v.insuranceInstance.Name}"
                                   maxlength="20"
                                   required="true"/>`

the 'v.insuranceInstance.Name' doesn't persists its value.

  • You seem to have two very different situations here. In the 1st, you define attribute as "student" then cast it to bind to "patient". In the latter, you define "insuranceInstance" but don't do any casting to another "type". – crmprogdev Apr 15 '18 at 12:25
  • Hey @crmprogdev , thanks for the reply, yea the first part 'using student instead of patient was a typo in the post, which I've corrected, can you plz breif more about the latter point regarding the casting of 'insuranceInstance'. – Himanshu Apr 15 '18 at 13:55
  • If the 1st one regarding student vs patient was a typo, then ignore my comment. I was primarily noting the inconsistent application of your code. If the latter doesn't persist, I'd suggest you look to how it's stored in your controller. – crmprogdev Apr 15 '18 at 14:48
  • @crmprogdev Thanks for replying, but the point is I'm not fetching any value in Init js over my controller, these are two fresh instance attributes that I've created only as a part of aura:attribute over markup , and which later on I'll be saving to the DB using the controller. – Himanshu Apr 15 '18 at 16:35
  • 1
    Hey @cmpprogdev, thanks for replying, I found out the root cause of the issue, it was becuase of the design attribute that I had linked with input flow variable (not sure why it would throw err as well though), but once I removed it from input parameter of flow, it worked alright! – Himanshu Apr 17 '18 at 6:08

Your Answer

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

Browse other questions tagged or ask your own question.