Queue click dynamically updating 2 models?


I have the following page that I am trying to get working.

  • A panel with a queue on the left that holds a set of Competencies in a Competency Model
  • 2 field editors (no page includes) that I want to update on the right of the panel when the queue item is clicked. The first, a read-only model is the ActiveCompetency, which is based on the same Object as the Competencies model, but is a single record, with a description of the competency I need to evaluate as part of an employee appraisal. This is based on the idea from this post. I have this bit working.
  • The second field editor is either a new or loaded editable component based on a CompetencyAssessment object, which is keyed off 2 other objects, ActiveCompetency and Appraisal, to enable me to make a specific assessment of a specific competency on a specific appraisal (which is in turn linked to a specific user). This second field editor does not render at all (I have the 2 field editors in the right panel, one of top of the other).
I have tried the following actions triggered by a click on the queue:
  • Save the CompetencyAssessment model (if it exists) to avoid losing unsaved data as the user clicks different items in the queue. Note that this save could fail if there is no model to save, but it should fail gracefully (and silently).
  • Activate a Model Condition to set the ActiveCompetency where clause so that the correct item renders in my top field editor
  • Query the Active Competency Model.
  • Query (if it exists) the CompetencyAssessment model (to load this into the editor, if it exists). OnError (ie, if this query doesn’t load anything) then it means there is no assessment in this appraisal for this competency, so create a new row on this model.
The issue that I am having (in the first instance) is that the second field editor is not rendering at all.

All the models are not set to load on page load, but are loaded only via Actions. 

I hope this is clearly enough explained… I appreciate any suggestions.


A few things.

  1. Your last bullet point. You misinterpret the meaning of OnError. This is more of a “Something’s broken” in the query vs. there are no records to display.
  2. There are often issues querying models separately that relate to each other in any way. I suggest that you query both models in one action. It seems counter intuitive in many cases, but I have run into this being an issue on more than one occasion. I still don’t fully understand why it’s an issue to query separately.
  3. The last thing to do is set the CompetencyAssessment Advanced setting “Create default row if Model has none” to checked.

Thanks Pat, I’ve addressed your points 2 and 3 which covers 1. Now I get the second Field Editor, but not the first!  I am going to try a pop-up now for the second one…

This would be much faster in a screen share. lemeno. I use skype.

You cannot do the “if then” calculation on the Compentency Assessment model using the action framework.

You can do that on page load - which would happen if you built the queue with a page include.   Use the model property “Create new row if none exists” if you go this route. 

If you really need to keep this on one page - you will have to do this “if then” operation in a Snippet. 

Rob, I was kinda expecting it’d come to that… The reason I don’t want to use an include is the chance of a user losing data if they click off one queue item onto another before saving. From what I’ve read on the post i refer to above, it’s not possible (easy?) to prevent this with page includes… This is all the more important as the data I’m capturing could be large (big Rich Text Area field) so I absolutely need to make sure it isn’t lost inadvertently…

That being said, this queue + 2 other models structure is in only one step of a wizard which will have 5 steps, all having a similar queue + 2other models requirement.

So it’s probably going to look like a massive page by the end of it all…

So, given all this, what do you recommend? Is it worth going down the include route anyway, and then using javascript to force the saving on click-off? Or any other design suggestions?



Rob, could you give me a rough idea of how to set up this snippet please? I’m happy to hack away at some JS, but I’m not certain how to set up the code wrappers/callbacks,  and so on…

Is there a guide or help-file somewhere, or a sample bit of JS I can modify?

Many thanks.


Actually most of what you need can be accomplished in the Action Framework,  there is just one peice that will require a snippet.  The snippet will be pretty painfully simple. 

Here are the action framework steps for loading the CompetencyAssessment model and if no rows exist - create a new one.  This sequence can be included with others. 

1. Activate condition on the CompetencyAssessment model and send the value of the Queue item. 
2. Query the Compentencey Assessment model. 
3. Run the snippet (with the name you assign below)

The snippet will look like this. 

var model = skuid.model.getModel('CompetencyAssessment'); if (model.data.length === 0) {model.createRow({editModeForNewItems : true})} else {return}

All our API doc is located here.  This snippet uses the skuid.model.Model API. 

Many thanks, Rob… I’ll give it a go tomorrow.  – Brad