setCondition does not return the filtered data

Hi,
I was trying to deactivate some conditions and keep 1 live condition active and bring some data based on that,but the below code doen’t query the new data rows as I expected.

I still can see in the console, the query is modified as I expected though the getFirstRow() returns nothing

Please help, Thanks in advance.

var EventRelationModel = skuid&#46;model&#46;getModel('EventRelation');<br />var EventRelationsData = EventRelationModel&#46;getFirstRow(); <br />var WhoModel = skuid&#46;model&#46;getModel('Who');<br />var WhoData = WhoModel&#46;getFirstRow();<br />if((!WhoData) &amp;&amp; (existingEvent&#46;WhatId === null || existingEvent&#46;WhatId === 'undefined' || existingEvent&#46;WhatId === '')) {<br /> <br /> $&#46;each(WhoModel&#46;conditions,function(i,condition){<br /> <br /> if (condition&#46;name &amp;&amp; condition&#46;name !== 'whoFilter4'){ <br /> WhoModel&#46;deactivateCondition(condition,false);<br /> }<br /> });<br /> <br /> var whoFilter4 = WhoModel&#46;getConditionByName('whoFilter4',false);<br /> WhoModel&#46;setCondition(whoFilter4, EventRelationsData&#46;RelationId);<br /> WhoModel&#46;updateData();<br /> <br /> WhoData = WhoModel&#46;getFirstRow();<br /> <br /> &#47;&#47; THIS PRINTS UNDEFINED<br /> console&#46;log('TEST DATA ------ ');<br /> console&#46;log(JSON&#46;stringify(WhoData));<br /> console&#46;log('TEST ------ ');<br /> EventModel&#46;updateRow(<br /> existingEvent,{ WhatId : WhoData&#46;AccountId}<br /> );<br />} <img src="//discourse-cloud-file-uploads.s3.dualstack.us-west-2.amazonaws.com/skuid/original/2X/a/a90f6c62aa8b8d9561841ee2c61f7a31fdd0ce9b.png" /> 

Hi All, found the issue here, due to asynchronous Skuid Model operation  I need to perform the updateRow withing the call back of the updateData() function;
see the solution below;

Cheers!

var EventRelationsData = EventRelationModel&#46;getFirstRow(); var WhoModel = skuid&#46;model&#46;getModel('Who'); var WhoData = WhoModel&#46;getFirstRow(); if((!WhoData) &amp;&amp; (existingEvent&#46;WhatId === null || existingEvent&#46;WhatId === 'undefined' || existingEvent&#46;WhatId === '')) { var filter2 = WhoModel&#46;getConditionByName('whoFilter2',false); var filter3 = WhoModel&#46;getConditionByName('whoFilter3',false); WhoModel&#46;deactivateCondition(filter3,false); var filter4 = WhoModel&#46;getConditionByName('whoFilter4',false); WhoModel&#46;setCondition(filter2, EventRelationsData&#46;RelationId); WhoModel&#46;setCondition(filter4, EventRelationsData&#46;RelationId); WhoModel&#46;updateData(function() { WhoData = WhoModel&#46;getFirstRow(); EventModel&#46;updateRow( existingEvent,{ WhatId : WhoData&#46;AccountId} ); }); }

Thanks! Just curious, how did you figure out that the condition setting function was performed asynchronously?

All network requests are naturally Async. The issue here was activating the condition by calling updateData() which fetches the data for the model (using the network) with the given condition, that’s why the fix was to put the updateRow() inside the callback from updateData().

Ah thanks, Velvel. I was setting a condition inside of a snippet and trying to update the model outside of the snippet, using declarative actions, right after.
When updating model data outside of the snippet context, the query conditions weren’t taken into account.

I didn’t add the condition to the callback function, but so long as the update was happening inside of the snippet context after the conditions were set, the query took into account the set conditions.