Aggregate model condition is not activated from JS snippet on applying the filter from other model a

Prateek KumarPrateek Kumar ✭✭
edited September 10, 2019 in Questions
I have model A - (Aggregate Model, with condition which is always off) and on Model B (Basic Model) there is a UI only formula field which is MODAL_LOOKUP to get the value for that specific row from the Model A.

Now, the scenario is in this way, the Model B is using the UI only field to show the sum of multiple child for each row, which is working as expected.

UI-only field on Model B
ABS( MODEL_LOOKUP( ModelA, sumOfAllChildRecords, {{KeyFieldfromModelAId}}, {{KeyFieldfromModel2Id}} ) )

And, on Model B there is multi-select picklist filter based on type of the child, So, I have created a action based on the filter condition, that whenever the condition is applied run a JS Snippet.

JS Snippet

var params = arguments[0],$ = skuid.$;
var filterItems = params.newValues;
var ModelA = skuid.$M('ModelA');
var ChildTypeCondtion = ModelA.getConditionByName('ChildTypeCondtion');
ModelA.setCondition(ChildTypeCondtion,filterItems); ModelA.activateCondition(ChildTypeCondtion);

This snippet is running whenever I apply the filter, So, I am expecting that it should also update the rows of the Model A, if the condition is activated, and applied.

And the same if you turn on the condition intentionally by default from the Skuid Builder by hard-coding a value then it returns the expected result.

I want this to updated dynamically based on the filter applied on Model B


  • edited September 6, 2019
    Any reason for using code instead of doing this with a model action? Condition on Model A should be filterable default off. On Model B, have an action whenever condition is change to activate & set the condition on Model B and put in {{newValues}}  as the value, then have an action to Query Model B. You'll probably also need to cover the other scenarios (deactivated, activated, reset).

    You'll also need an action to evaluateFormulaFields for Model A whenever Model B is requeried. Also if that UI-only formula is a direct copy & paste, it could also be having some issues since it looks a little off.
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!