I have a custom module that i want to use on a dynamic page. The dynamic pages data source is an Event CRM object. When the event template renders i want to pass in the current event to a module as a parameter so i can use one of the event properties in my module.
I am unsure how to pass in the CRM object to the "how_to_enter" module. I tried event=event and as a custom object like above but when i render the event in the module like so
{{ module.event | pprint }}
This just equals "null".
The field "event" in the module is defined as a crmobject and is "locked: true" so it cant be set on the template itself.
Any idea as to what i am doing wrong? I cant find any documentation on passing values in the template for crmobject type module fields.
Understood! Apologies for the question, but just want to make sure that the ID itself is making it out of the query you've got. Does {{ event.hs_object_id }} return anything at the template level/is it one of the properties that has been specified in your query? I'm sure you've got it, but just wanted to cross that out for sure.
The way that the CRM object field in your module should expect it is something like the following:
even if the ID was recognized, but nothing was found to match it.
Another option to consider that may work, but could also complicate things, is to utilize "dynamic_page_crm_object.hs_object_id" if this is a dynamic CRM object page and if your query itself isn't handling any additional filtering. If that is the case, you could potentially use it directly in the module itself to define your event as a fallback if no event record has been manually selected!
Let me know if the above gets us any closer and we can go from there if not!
I think the first thing I would check is that we are getting a value back at the template level for your "event" variable. The only way I was able to replicate this exact situation in my test account was when the ID that I was passing into the module field settings was not defined.
If you are getting a value back from your "event" at the template level, we'll want to make sure that it is something we can dot notate through. I'd imagine it should return as an object type by default, but you'll want to check that it isn't a single object within an array.
Let me know what you find and we can work on debugging things further!
At template level i am getting back the "event" information from the graphql query, so i am able to output properties without issue on the template itself, so for example event.name will output via hubl in the template without issue. It is only when i pass this event to the module as a prop e.g.
{% module "how_to_enter"
label="How to Enter"
path="../modules/how-to-enter"
event=event
%}
that when i "pretty print" the modules data from inside the module, i.e. {{ module | pprint }} the "event" property is null.
I wanted to try and use this way so i could pass the event object as a whole to the module. I havent yet tried to change the "event" field in the module to be a number, pass the ID to the module from the template like
{% module "how_to_enter"
label="How to Enter"
path="../modules/how-to-enter"
event=event.hs_object_id
%}
and then fetch the event again from the module. I didnt want to do this, in case it queries twice. First on template load and then on module.
Please let me know if you need any more information or if i can help any further to understand the issue.
Understood! Apologies for the question, but just want to make sure that the ID itself is making it out of the query you've got. Does {{ event.hs_object_id }} return anything at the template level/is it one of the properties that has been specified in your query? I'm sure you've got it, but just wanted to cross that out for sure.
The way that the CRM object field in your module should expect it is something like the following:
even if the ID was recognized, but nothing was found to match it.
Another option to consider that may work, but could also complicate things, is to utilize "dynamic_page_crm_object.hs_object_id" if this is a dynamic CRM object page and if your query itself isn't handling any additional filtering. If that is the case, you could potentially use it directly in the module itself to define your event as a fallback if no event record has been manually selected!
Let me know if the above gets us any closer and we can go from there if not!
Sincerest apologies for my late reply. Thanks again for assiting with this.
Interestingly, i have been able to get this to work as you mentioned using
event={
id: event.hs_object_id
}
but i have to create a fresh version of the module i.e. add a new one to the page with a different name so instead of {%module "name" %} its {%module "name_2" %} as an example.
Unfortunately, the issue i have after this though is if i change any other field on the module from the site editor it overrides and removes the event so therefore it is null again. Even if the event field itself is set to "locked" and therefore i would expect not affected by the editor changes as its expecting to be set at template level anyway.