0

I am just trying to create a VF page where I should be get a list of related child object when i click the parent object (Account).

<aura:component controller="GetAccountAndProduct_Display__c">
  <aura:attribute name="accounts" type="Account[]" />
  <aura:attribute name="productDisplay" type="Product_Display__c[]" />
  <aura:handler name="init" value="{!this}" action="{!c.doInit}" />
  <div>
    <div style="text-align:center;font-size:25px"> Accounts </div>
    <aura:iteration items="{!v.accounts}" var="acc">
      <div class="slds-truncate" title="Adam Choi">
        <a href="javascript:void(0);"
          onclick=" {!c.Clicked} "
          data-value=" {!acc.Id} " >
          {!acc.Name}
        </a>
      </div>
    </aura:iteration>
    </div>
  <div>
    <div style="text-align:center;font-size:25px"> Product_Display__c </div>
    <aura:iteration items="{!v.Product_Display__c}" var="con">
      <div class="slds-truncate" title="Adam Choi">
        {!Product_Display__c.Name}
      </div>
    </aura:iteration>
  </div>
</aura:component>

enter image description here

Can someone suggest how to remove the error. I am totally unaware I just got the coding from google and I am a non-coder. Would appreciate much If you can find the error.

4
  • where you have declare and used foo, bar attribute. put other code so we can help.
    – Amol
    Dec 29, 2019 at 7:42
  • Hi Amol, I have posted my code above..Will this help Dec 29, 2019 at 7:52
  • replace the {!Product_Display__c.Name} to {!con.Name}
    – Amol
    Dec 29, 2019 at 8:42
  • You say you're trying to create a Visualforce page, but this is a Lightning component. Those are entirely different, and not always compatible, technologies. Additionally, your objective sounds like it duplicates native Related List features or Lightning components. There may be more idiomatic ways to achieve your underlying objective.
    – David Reed
    Dec 29, 2019 at 18:55

2 Answers 2

1

The second aura:iteration has to have it's items pointing to an array - right now it's pointing to something v.Product_Display__c that doesn't exist. You need to use the v.productDisplay variable.

Try this:

    <aura:iteration items="{!v.productDisplay}" var="product">
      <div class="slds-truncate" title="Adam Choi">
        {!product.Name}
      </div>
    </aura:iteration>
1
  • 2
    That's another issue, but not the one causing this specific error.
    – sfdcfox
    Dec 29, 2019 at 9:27
4

In Aura, you cannot use spurious spaces wherever you like. This specific error is likely from code such as:

      data-value=" {!acc.Id} " >

The extra spaces surrounding the string makes the system think you're trying to combine a string literal with a variable. This is not allowed.

Make sure you do not use extra spaces in attribute values that include merge values:

      data-value="{!acc.Id}">

You must log in to answer this question.

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