Context in template component

Hi all,

I have a visualforce page to show a map in the detail page of a country. I have it in the detail page and its working perfectly,

Now I’m doing a list of countries with a table and drawers, the list is based in country regions (Africa, Europe, Asia, North America, South america, Pacific islands,…).

For each region you can open a drawer in the table to see a table of countries and for each country you can open a drawer to see the information of the country.

I have 3 models, Region, Countries of the region and Country Info. This is a simplyfied version of what I have (there are another tables with other country lists inside tabs, the purpose of the Country Info model is not to populate all the country information in all the different country models I have)

When I open the drawer all the conditions are set and the field editors and tables are with the context configured to show only the information of the region opened and the information of the country opened.

All is working correctly but I have a template component in the country to show an iframe of the map of the country linked to the country information model.

That model is queried each time to add the opened drawer data.

The problem is if I open 3 drawers the template shows 3 maps, each map of each country I have opened.

So, my question is: Can I set the context of a template field to prevent this? 

In the drawer “Before Load” actions, did you set the query action to the non default option? I think it’s called “Get more Rows” .

I have setted to add rows to not to loose the other drawers info

Pablo,  I’m confused.  The expected behavior is that when you open a drawer,  the components inside that drawer operate in the context of the table row.  If the template is bound to the same model as the table this will work without any further definition.   But that does not seem like the behavior you are looking for. 

Do you want all the three maps to show three different countries?  I think this should work.  Or do you want the three maps to show all the countries for drawers that have been opnened. I don’t think this will be possible without some substantial custom code. 

I think that only components that offer this setting can be set using context. Here’s a list of components that do offer this setting.

  • Field Editor
  • Table
  • Page Title
  • Queue
So, that said, you have to come up with a way to set the template on drawer load. Merge Syntax in Templates update as changes are made to the referenced field. I wonder if there’s a way to set the values of Template field using javascript. If so, it shouldn’t be all that difficult to do.

It would great to be able to use merge syntax with the option to merge once and not update.

You can however use a template field within a Field Editor component. This would have the Id of the row in context.

It’s what pat comments, you can only set the context to certain components.

The template is linked to the model that has 3 rows but in the drawer is only showing 1 row in the field editor because of the context.

mmm ok, I will investigate the javascript option,

I can create with a template something like <div class=“map” id=“COUNTRYID” and every time a drawer is open for each .map get the ID and put the map.

But, If I execute this code before open, the div with the map won’t exist in that moment, so is going to put the map in all the drawers opened before but not in this one.

I would try using a Field Editor with a Template within it first. This should work in 5 minutes.

Good good, you are good

It works perfectly.

You are the man. Thanks

yw. :smiley:

Two years later, and yes, using the mB Template you can now have Context in a template component! (At least, in the builder. The functionality was already there, just hidden)

Please visit  for installation instructions, 
updated instructions, new versions of this and other components!