0

I am trying to pass a value from parent to child component in the following manner

<c:contactSelect accountId="{!IF(v.proposal.CurrencyIsoCode != 'US' && v.proposal.BillingCountry__c != 'US' && v.proposal.ResellerPartner__c != null, v.pubQuoteDocuSign.proposal.ResellerPartner__c, v.proposal.Proposal__Account__c)}"/>

However, when I try to save the above piece of code it gives me the following error

Failed to save pubQuoteDocuSignComponent.cmp: c:pubQuoteDocuSignComponent:44,260: ParseError at [row,col]:[45,260] Message: The entity name must immediately follow the '&' in the entity reference.: Source

Is this not the correct syntax?

2

Because these components are XML, you need to escape the & character (this character is used to render unprintable characters, etc). You escape ampersand with &amp;, as in:

<c:contactSelect accountId="{!if(v.proposal.CurrencyIsoCode != 'US' &amp;&amp; v.proposal.BillingCountry__c != 'US' &amp;&amp; v.proposal.ResellerPartner__c != null, v.pubQuoteDocuSign.proposal.ResellerPartner__c, v.proposal.Proposal__Account__c)}"/>

This is called out in the documentation.

It's worth noting that the and() function is preferred for this reason.

<c:contactSelect accountId="{!if(and(and(v.proposal.CurrencyIsoCode != 'US',v.proposal.BillingCountry__c != 'US'), v.proposal.ResellerPartner__c != null), v.pubQuoteDocuSign.proposal.ResellerPartner__c, v.proposal.Proposal__Account__c)}"/>

and() only works with two operators, so you have to nest them if you need more than two.

Finally, note that these operators are case sensitive. You can't use IF instead of if.

1
  • Thanks a ton. That was very helpful. I ultimately ended uo using the second approach that you provided. – Madhurima Apr 11 at 6:43

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.