Calendar: second popup not getting context.

Calendar popup has stopped getting context.

When I open the popup and type
skuid.$M(‘AllAppointments’).getFirstRow()
in the javascript console, I get a different row than the current context.

This is causing problems when I try to use the values of the current row in javascript.

Any idea what could be causing this?

A look under the covers will help here.  Context is not the same thing as model.  It is a subset of model data that is connected to a particular row of the model (or another model). 

When you look for data in the console using “skuid.$M(‘AllAppointments’).getFirstRow()” You are returning the first row of data in the model.  It may or may not be connected to the context of the calendar date (or table row) you have specified. Because context is very much dependent on the UI component,  There is not a good way to debug context in the browser console.  What I usually do is include a template in the popup where I want to set the context and expose the record ID, or some other identifying value.  This will show you how context is filtering the model. 

Another few notes…

Context occurs completely client side.  This means that all the fields you are using to compare the popup data with the calendar entry data have to be in the paricular models. 

Context will not automatically query the sObject to return the data you want to expose that is related to the calendar entry.   If that related data is not in your model, nothing will show.   We typically use the action framework to pass a value into a condition on the related object model, requery the model,  and then open the popup that has its components set to filter to the particular context. 

In a similar fashion, if you are trying to use the value in context in javascript, you might query the model on every calendar click - returning just the data that is related to that calendar item.  Then your javascript model reference will be correct. 

Hope those ideas help…

Rob,

Thanks for the clarification.

What’s the best way to query the model on calendar click?

Looks like “Run snippet and show custom popup” is the way to go. Seems like calendar click would be a natural place for the action framework. Anything like that in the works?

Thanks. Got it working!

Dangit.  I forgot that we hadn’t wired up calendar clicks to the action framework yet.  It is a known issue that we have not solved.  Sorry.