Adding Conditions to an Extant Model. Is it possible?

Hi Guys,

I’ve got a use case where I want to filter a model based on varied conditions that a user might select. The problem is that I don’t know what these conditions will be ahead of time.

So my question:

Is it possible to add conditions to a model at dynamically at run-time? I don’t mean activating quiescent conditions with setCondition, but rather adding a totally new condition and re-querying an existing model.

I’ve tried variants of this type of thing, but just can’t get the new condition into the query.

var tasksModel = skuid.$M('Tasks');<br>tasksModel.conditions.push({ type: 'fieldvalue', field: 'Id', operator: '=', value: 'Apple', inactive: false, name: 'Apple', encloseValueInQuotes: true }) tasksModel.initialize().register().updateData(); tasksModel.soql;<br>



Any ideas would be greatly appreciated.

Thanks,
Dan Arnison
PractiFI

Dan,

I would have expected what you’re doing there to work.
Perhaps include

tasksModel.isInitialized = false;

 before you initialize and query again?

Perhaps try creating a ‘blank’ condition, and modifying the values of that condition via javascript?

Alternatively, you can just dynamically create the whole model.

Thanks Matt. I gave that a try; no joy.

Also, I cannot readily create a new model dynamically because existing components are bound at design time.