help with using an iframe (merge syntax issue)

edited June 25, 2020 in Questions
I'm trying to display an element from an app (matchmyemail) by using a template/iframe. It works when I use the url I got by inspecting the element and keep the specific record ID as is. I can't seem to get it to work though whenever I try to replace the ID with any merge syntax

Here's the error message I get in the editor page with all the attempts I've made so far:

"Visualforce Error
Id value is not valid for the Contact standard controller"

Here's the syntax I've last tried:
<iframe src="https://mme.eu3.visual.force.com/apex/EmailMessagesContact?id={{{id}}}"; ย width="100%" height="500"> </iframe>
Any help would be appreciated.

Comments

  • Rob HatchRob Hatch ๐Ÿ’Ž๐Ÿ’Ž๐Ÿ’Ž
    edited September 1, 2016
    Ahmed - that error message is probably one of two things.ย 

    1. Field references are case sensitive. I'm 99% sure that the reference to contact Id needs to be "Id" rather than "id"
    2. You might also haveย the template component tied to a model that doesn't have Contacts in it. ย 

    For both cases,ย a nice hack for troubleshooting is to put the merge fields you are trying to pass as URL parameters outslde the HTML code in your template. ย In this case it might be:ย 
    ID = {{{Id}}}
    <iframe src="https://mme.eu3.visual.force.com/apex/EmailMessagesContact?id={{{id}}}"; ย width="100%" height="500"> </iframe>
    This way you can make sure your data merges are good before you go on to make sure your VF code is good.ย 
  • edited September 13, 2015
    Thanks Rob, that was lightning fast! I am unfortunately having no luck yet. I indeed did have the "id" all lowercase. Changing that didn't change much. The template is tied to the main model (Contact in this case).

    I just tried doing this for another custom object (in case this was an issue unique to standard SF objects) but it's still behaving the same way.

    Any other thoughts or suggestions?

    Thanks for the url hack, it sure seems handy.
  • Pat VachonPat Vachon ๐Ÿ’Ž๐Ÿ’Ž๐Ÿ’Ž
    edited June 25, 2020
    That error doesn't mean it won't work when accessing the page. I know because I just finished putting Cirrus Files in a template using an iFrame.

    image

    Does work without issues.

    image
  • edited September 13, 2015
    Thanks Pat, That was worth a try. Unfortunately, I get the same error message when I load up the tab with the template in question on the regular page. I feel the problem is a simple syntax issue since it works when I use specific ID values in the iframe src (but I could be wrong, of course)
  • Pat VachonPat Vachon ๐Ÿ’Ž๐Ÿ’Ž๐Ÿ’Ž
    edited June 25, 2020
    You have the ID field in your model? Tried both {{Id}} & {{{Id}}}?
  • edited September 13, 2015
    yup. tried 1-4 curly brackets, all with the same -ve result
  • Pat VachonPat Vachon ๐Ÿ’Ž๐Ÿ’Ž๐Ÿ’Ž
    edited June 25, 2020
    Can you take a screenshot of the template that does work. The one where you set the record Id manually.
  • Rob HatchRob Hatch ๐Ÿ’Ž๐Ÿ’Ž๐Ÿ’Ž
    edited September 1, 2016
    Ahmed - ย I'm almost sure your template is not accessing the data you are thinking it is accessing. ย Use the troubleshooting hack I posted above to show you explicity what ID value is being passed from your model into your template component.ย 

    Also ย - use the field picker next to the template field to ensure the correct spelling and case of field names.ย 

    Some ideas.ย 

    Is it 18 char ID or 15 char ID you want. ย {{Id15}} will return the 15 char value while {{Id}} returns the 18 char value.ย 
    Is the template connected to the appropriate object
    Are you really trying to get a parent record Id or a child record ID? ย Then {{Id}} will not be correct.




  • edited September 13, 2015
    Rob, thanks for all the neat tricks and tidbits. On the 18 vs. 15 chars. I did notice it did use only 15 chars when I first copied the src url using the inspect element. But it seems fine with 18 chars as well (see images below). I tried using {{Id15}} instead but with no luck. I assume I am using the correct model (main detail model for this page (Contact in this case) to who which the param ID belongs and the template works when I replace the curly brackets with the actual Id). I'm not sure I'm following your point about parent vs. child. But in case this is relevant, I'm using the Contact model and this is a Contact detail page. Pat, Rob, here are some screenshots: Edit page with specific contact ID plugged in (note the application is rendered and working in the preview box below) image I plug in the merge syntax (using the field picker this time, thanks Rob) for the contact Id and am immediately prompted to leave the page image If I choose yes, then I get this error page (note the url) image Oh, and here's the page previewed to show the ID hack in action. Seems to work fine when not part of the iframe (I'm using the specific contact Id (same as in the 1st image above)) image And for what it's worth, here the preview with the element inspect (sharing in case it might add anything here) image
  • Pat VachonPat Vachon ๐Ÿ’Ž๐Ÿ’Ž๐Ÿ’Ž
    edited June 25, 2020
    Got me stumped.
  • Rob HatchRob Hatch ๐Ÿ’Ž๐Ÿ’Ž๐Ÿ’Ž
    edited September 1, 2016
    So wait. ย When you are in the builder, ย and you replace the hacked ID number with {{Id}}, ย you immediately get a unsaved changes warning?ย 

    What happens if you "stay on the page" and then use the preview function?ย 

    PS - I'm 99% sure you will need to use triple braces around that Id. ย As in {{{Id}}}


  • edited September 13, 2015
    Thanks Rob, it finally worked!!!!

    So to summarize for anyone who happens to run into the same issue and doesn't want to put all the pieces from above.

    When you are having trouble with replacing a specific record Id with the curly brackets and face similar symptoms (immediate request to reload page followed by the same error message when you insert the merge syntax in the editor), make sure you:

    -use triple brackets
    -make sure the "I" in Id is upper case (and "d" is lower case)
    -do not refresh the page upon prompting
    -use the preview button instead
    -use the hack that Rob mentioned above (it helped me make sure I was doing some things right)
  • Rob HatchRob Hatch ๐Ÿ’Ž๐Ÿ’Ž๐Ÿ’Ž
    edited September 1, 2016
    Glad you got things working Ahmed.. ย Sorry it took so long.ย 
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!