1

I am bulding the URL with attribute values., so I am getting this error. Is there a way we can have multiple attributes in URL?

<a href="{! 'http://example.sample.net/forms/view/261086?tfa_98=' + v.timesheetRecord.Internship__r.Student_Contact__r.Id + '&tfa_99='+v.timesheetRecord.Id }"   target="_new" > 

Error:

Failed to save sendTimesheetEmial.cmp: 0Ad0t0000008k7m:58,170: ParseError at [row,col]:[59,170] Message: The reference to entity "tfa_99" must end with the ';' delimiter.: Source

2 Answers 2

4

You need to escape the & using an XML character entity:

'&amp;tfa_99='
1
  • That worked. I will keep track of this for future.
    – Ajay
    Commented Feb 9, 2018 at 21:22
0

@Ajay, I am not familair with your specific use case, however, you are not the first person asking <a> tag related questions related to lightning components.

Please check the Lightning Components Developer Guide in regards to using Anchor tags:

Don’t hard code or dynamically generate Salesforce URLs in the href attribute of an tag. Use events, such as force:navigateToSObject or force:navigateToURL, instead.

Avoid the href Attribute

Using the href attribute of an tag leads to inconsistent behavior in different apps and shouldn’t be relied on. For example, don’t use this markup to link to a record:

<a href="/XXXXXXXXXXXXXXXXXX">Salesforce record ID (DON'T DO THIS)</a>

If you use # in the href attribute, a secondary issue occurs. The hash mark (#) is a URL fragment identifier and is often used in Web development for navigation within a page. Avoid # in the href attribute of anchor tags in Lightning components as it can cause unexpected navigation changes, especially in the Salesforce app. That’s another reason not to use href.

3
  • That's good Salesforce-specific advice, but wouldn't be applicable to links outside of Salesforce.
    – sfdcfox
    Commented Feb 9, 2018 at 18:48
  • indeed, just hoping the OP is aware of this, and if not, will be for future reference =)
    – glls
    Commented Feb 9, 2018 at 18:50
  • I agree, I have to put this link in between the text. Unavoiadable.
    – Ajay
    Commented Feb 9, 2018 at 21:21

You must log in to answer this question.

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