Passing URL Parameters to a Page Include

  • 1
  • Problem
  • Updated 4 years ago
  • Solved
Hi there, 

I'm having some troubles passing URL parameters to a page include. 

Here's the example: 

I have a page called TaskLogCall that accepts parameters to populate WhoId and WhatId



On my contact detail page, I create a popup with a page include that includes the TaskLogCall page. 

In the field for setting the querystring, I pass in the parameters required using the same format as on this documentation page



Expected result: beautiful pre-populated fields in my pop up. 

Actual result: painful emptiness. 


What am I doing wrong? 

Thanks. 
Photo of Justin Norris

Justin Norris

  • 782 Points 500 badge 2x thumb

Posted 4 years ago

  • 1
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Does the page you're calling the page include from already have a URL parameter Id? Not sure this would cause an issue though.
Photo of Justin Norris

Justin Norris

  • 782 Points 500 badge 2x thumb
It does indeed have an "id" condition on the main contact model. But I would thank that a page include would be like it's own self-contained little universe, no? 
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Not sure, but it's quick to test that.
Photo of Justin Norris

Justin Norris

  • 782 Points 500 badge 2x thumb
Hmm, how would I do that without breaking my contact detail page though? Or do you just mean giving it a distinct parameter name so the two don't potentially mix up? 
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Change the page include page model condition name to whoid vs just id. Then update the query  string to reflect that change.

?whoid={{$Param .....
(Edited)
Photo of Justin Norris

Justin Norris

  • 782 Points 500 badge 2x thumb
OK thanks. Have to step away for a bit but will give that a try. 
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
I may not be up to speed on this, but does this page include have model to handle the contact and account? The models will need to be loaded prior to the task model in order to properly set the task whoid and whatid to the id of the current contact and account model.
Photo of Justin Norris

Justin Norris

  • 782 Points 500 badge 2x thumb
Hi Pat, yep the page has those models and works fine when used as a stand-alone page. Just can't get the parameters to pass into the include. 
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Try passing them into simple text fields to see if they arrive at all.

Rob was saying something about the 15 vs 18 characted id being an issue. Not sure if that applies here.
Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb
Have you inspected the generated URL? Does it contain what you coded and expect? You may need to open Chrome Developer tools to see it since it is a page include in a pop up.
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
This possible? To get the URL of the page include? How?
Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb
On second thought, maybe not, if the pop up is included in the initial page load. Open Developer tools and check out the network log entries when opening the pop up. You can also review page source. I have not tried this and maybe way off base. Just thinking out loud.
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
I always think out loud. It's very noisy! :Pat
Photo of Justin Norris

Justin Norris

  • 782 Points 500 badge 2x thumb
Irvin that is a good idea. I can't find the actual querystring in the HTML of the page though unfortunately. It looks as though maybe the actual URL is not rendered in the pop up so I can't find it in the inspector (unless I'm missing it). 
Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
Assuming that you have a Model called "Contact" on your Contact detail page, you could use this as the Query String instead:

?id={{$Model.Contact.data.0.Id}}&whatid={{$Model.Contact.data.0.AccountId}}

This is more explicit.

But the problem with the above may be Capitalization, if your parameter in the URL ends up as lower-case "id" or lowercase "accountid", then your Query String has to use Lower Case as well, that is:

?id={{$Param.id}}&whatid={{$Param.accountid}}
Photo of Justin Norris

Justin Norris

  • 782 Points 500 badge 2x thumb
Hi Zach, 

I tried the more explicit method, only changing the name of the model to ContactData to reflect my model name. 

This is what I have now: 

?id={{$Model.ContactData.data.0.Id}}&whatid={{$Model.ContactData.data.0.AccountId}}

This is what I get on my popup page include now



The WhoID is working fine.

The WhatID is passing but not being converted to a name for some reason.

Furthermore, the page is now displaying this error:

 

Note both the original page (ContactDetail) and the included page (TaskLogCall) contain Account and Opportunity models with name and ID fields. 

How to fix? 

Thanks
Photo of Zach McElrath

Zach McElrath, Employee

  • 48,754 Points 20k badge 2x thumb
I would make sure that your Model Conditions, which are probably of type URL Parameter, are expecting the revised parameter names, in lower-case.
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Odd. The SOQL query doesn't have the value in it but it shows up in the page.
Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb
I would recheck the capitalization of the query parameters.
Photo of Justin Norris

Justin Norris

  • 782 Points 500 badge 2x thumb
Hey guys, no luck here. 

My WhoId is working fine so I left that be and tried lower-casing the WhatId like so: 

?id={{$Model.ContactData.data.0.Id}}&whatid={{$Model.Contact.data.0.accountid}}

It passed nothing and gave an error message again.

I also reverted to the $Param method and tried all lower case and got nothing in both cases. 

The challenge here is I am sure that the parameters being passed are correct for the included page (id and whatid, both lowercase). 

Now I need to correctly refer to the variables on the source model that I want to pass. Those variables appear in uppercase to me and when I lower case them they don't pass anything. 

AccountId does pass successfully when uppercased but then it only renders as the ID (not name) and gives the error messages. 

Do I need to be looking at URL params on the source page too? I would think those are separate but I am a bit lost now. 

Thanks for continued help. 
Photo of Greg Jarrett

Greg Jarrett

  • 3,496 Points 3k badge 2x thumb
Thought I'd take a stab at this one...are you sure the "Account.Name" field is also being pulled into the model which contains AccountId? Usually with reference fields I find the model needs to contain both the Id and and Name field to pass the actual name of the Account. I'd double check this field is in both the source & destination pages.

Photo of Zach McElrath

Zach McElrath, Employee

  • 49,056 Points 20k badge 2x thumb
One way to ensure that the Name value will pass in is to add a URL Parameter Condition on the "What.Name" field as well as on the "WhatId" field, and then pass in a value for What.Name via a "whatname" parameter, like this:

?id={{$Model.ContactData.data.0.Id}}&whatid={{$Model.Contact.data.0.AccountId}}&whatname={{$Model.Contact.data.0.Account.Name}}
Photo of Justin Norris

Justin Norris

  • 782 Points 500 badge 2x thumb
Hey Zach, 

Thanks for that - I have good news and bad news :) 

The good news is I used your querystring (I just changed "Contact" for the second two parameters to match my model name)

?id={{$Model.ContactData.data.0.Id}}&whatid={{$Model.ContactData.data.0.AccountId}}&whatname={{$Model.ContactData.data.0.Account.Name}}

And the page include now worked like a charm! WhoId and WhatId were rendered with names perfectly. 

However....(the bad news), it only works the first time. By this I mean, if I go to the page, click on the button to log a call, close the pop up window, then click on it again, the WhatId field is now blank

??

Even more weird, I added another pop up with a page include for my New Task page using a very similar querystring, and it will only work once between the two pop ups. So if I click New Task first, it will populate there  but then not again and not for Log a Call. Same thing in reverse if I click Log a Call first. 

I am very confused by this page's behaviour and more generally by how Skuid is using parameters and conditions to populate these fields. I'm sure there is an underlying order to things that I am not seeing, but right now it feels very sporadic. 

Please help me understand what is happening here :) 
Photo of Menachem Shanowitz

Menachem Shanowitz

  • 1,074 Points 1k badge 2x thumb
Use Javascript to update the page include. I had a similar issue and it worked for me like a charm. Put it in a snippet that is loaded after the popup using the multiple actions framework. 

Make sure your Page Include component has a Unique Id set, so that we can reference it via JavaScript:

var contactRow = skuid.model.getModel('Contact').getFirstRow();
var contactDataRow = skuid.model.getModel('ContactData').getFirstRow();
var pageInclude = skuid.$('#MyPageInclude').data('object');
pageInclude.pagename = 'TaskLogCall';
pageInclude.querystring = '?id=' + contactDataRow.Id + '&whatid=' + contactRow.AccountId + '&whatname=' + contactRow.Account.Name;
pageInclude.load(function(){
   console.log('done loading');
});

Javascript API taken from https://community.skuidify.com/skuid/topics/change_the_page_included_in_javascript
(Edited)
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
K. Something has gone wonky. Should be straight forward. This is driving me nuts. Let me know if you want to do a screenshare meeting on Skype. pat.vachon.77
Photo of Justin Norris

Justin Norris

  • 782 Points 500 badge 2x thumb
@Menachem, thank you very much for the code snippet. I tried it out and it doesn't seem to be changing anything unfortunately. 

When you say "Make sure your Page Include component has a Unique ID set" what does that mean exactly? 

Also note my page doesn't include any model called "Contact," I wasn't sure if that would make a difference here. For fun I did try the code and change it all to "ContactDataRow" and nothing changed. I am stumped. 

@Pat, I'd gladly take you up on it. Very nice of you. I'll add you on Skype and message me if you happen to be around. 
Photo of Menachem Shanowitz

Menachem Shanowitz

  • 1,074 Points 1k badge 2x thumb
You were correct, you should only use contactDataRow (and you can remove the first line 'var contactRow..'). The reason why it didnt work is because the page include Id property needs to be set to 'MyPageInclude' (no quotes). (You can set the Id to whatever you want provided that the code is updated with it.)
(Edited)
Photo of Justin Norris

Justin Norris

  • 782 Points 500 badge 2x thumb
@Menachem, I tried again and added the ID property to the page include. Unfortunately same results!

This is the code I'm using by the way: 
var params = arguments[0],	$ = skuid.$;
var contactDataRow = skuid.model.getModel('ContactData').getFirstRow();
var pageInclude = skuid.$('#MyPageInclude').data('object');
pageInclude.pagename = 'TaskLogCall';
pageInclude.querystring = '?id=' + contactDataRow.Id + '&whatid=' + contactDataRow.AccountId + '&whatname=' + contactDataRow.Account.Name;
pageInclude.load(function(){
   console.log('done loading');
});
@Pat, I also tried adding a "field from another model" condition to pull the Account ID (and also tried pulling Account Name) from the Account model instead of taking directly from the URL parameter into the Task model. 

In all cases I'm getting the same results -- perfect rendering the first time, bubkas the second time. 

I am open to all further suggestions. Thanks to you both very much again. 
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
You're saying that you click on the log a call button once, save the record and close the popup. You do this again and the second time the account data isn't showing up?
Photo of Justin Norris

Justin Norris

  • 782 Points 500 badge 2x thumb
Exactly!
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
K. Can't be the page include page. Something is affecting a model on your main page from the page include. Are any of the models in the page include named the same as the main page? Are any of the parameters in the query string named the same as the URL parameters on your main page.
Photo of Justin Norris

Justin Norris

  • 782 Points 500 badge 2x thumb
The only model that overlaps is the ContactData model, which also exist on the TaskLogCall page. 

The parameter "id" passing into the TaskLogCall page also exists as "id" on the ContactDetail page. 

So yes -- however, this field is working beautifully whereas it is the Account field that is messed up. 
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
For sure you will get problems if a model name is the same between include and main page. My guess is that this is what is happening. 

1. On initial page load ContactData model from "TaskLogCall" page is loaded and it includes the fields you expect to pass as parameters. 
2. When the include page is loaded the ContactData model is overwritten.  Though the parameter values are still in place and the include works. 
3. When you try to load include #2 the fields you expect to pass as parameters are no longer in the models (because they have been overwritten).  Hence the wierdness. 

Hope that helps. 
Photo of Justin Norris

Justin Norris

  • 782 Points 500 badge 2x thumb
Pat your comment was on the right track and Rob, you nailed it. (Thank you for responding especially Rob as I know you're on vacation right now.) 

I changed the model name on the ContactDetail page, updated the model references in the querystring, and we are off to the races. It works every time. Whoo hoo!

Thank you Zach, Irvin, Menachem and everyone else who tried to help me as well. What a relief to have this sorted! 

The universe makes sense again. 

Happy holidays all. 
Photo of Rob Hatch

Rob Hatch, Official Rep

  • 44,006 Points 20k badge 2x thumb
Seeing the community come together to help you out is a huge Christmas Present to all of us at Skuid.  Glad your universe is coherent again!  Enjoy the holidays...
Photo of Nicholas Playoust

Nicholas Playoust

  • 258 Points 250 badge 2x thumb
I am new to Skuid and have a very simple question about passing a record ID used on a Parent Page to a Page Include.  I cannot find documentation to achieve this and would appreciate if someone could point me in the right direction.

Thanks in advance.
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Two options. After placing your Page Include onto your page.
1. URL parameter via merge syntax. id={{$Param.Id}}

2. Id value from Model via merge syntax. id={{$Model.Account.data.0.Id}}
Photo of Nicholas Playoust

Nicholas Playoust

  • 258 Points 250 badge 2x thumb
Pat, thanks for your quick response.  Do I need a Condition on Page Include to filter the record ID?
Photo of mB Pat Vachon

mB Pat Vachon, Champion

  • 42,714 Points 20k badge 2x thumb
Yw.

Yes you do. I'd post this too but my heads on a pillow now.
Photo of Nicholas Playoust

Nicholas Playoust

  • 258 Points 250 badge 2x thumb
Thanks Pat.  After too many hours it now works! Thank you.
Photo of Irvin Waldman

Irvin Waldman, Champion

  • 9,006 Points 5k badge 2x thumb
(Edited)
Photo of Nicholas Playoust

Nicholas Playoust

  • 258 Points 250 badge 2x thumb
Irvin - thanks for those links.  Both are helpful.  Nicholas