Skip to main content

I have Multi-Pick list that when its values are checked it will Activate a condition in another model based upon what was selected.  This works great except when the user clicks “UnCheck All” and the condition appears to get set to “None” and thus my models return no data.  Additionally, I would also like to be able to default the Multi Picklist to be “All Values” rather than only one.

Jeff…

How about just deactivating your condition if the value is empty?


Makes sense and seems obvious… but how do I initiate an action based upon a value changing to empty.  If I was writing code I would use some kind of “if statement”, but I’m not clear on or or if I can do that.  For example… if field “MARKET__UI” = Null then fire the action “deactivate condition”


Jeff,

Yes, you’ll need some javascript.
How are you setting the values for the condition in the first place?

Assuming you’re using the action framework, it will probably be as simple as a “nullCheck” script like this:


var model = skuid.$M('MyModel'),<br>row = model.getFirstRow(),<br>returnVal = false;<br>if (model.getFieldValue(row,'My_Field__c')) {returnVal = true'}<br>return returnVal;


The action framework sequence will only continue if the snippet returns true. If it returns false, it will perform any “error actions” that you set up. (such as “deactivate” and “query”)


I have a Model UI_OnlyForFilters  It has a UI Only Field called MARKET__UI I have an action on this model that fires when MARKET_UI is updated to set a condition on another model called PastDueOpp to the value(s) selected in the MARKET__UI field.  (MARKET__UI is a multi-picklist field with a set of specific values).  After I set the value and activate the condition on PastDueOpp, I have a subsequent action that re-queries the PastDueOpp model.  The crux of my problem now is that if the user “UnChecks All” on the MARKET__UI field, my PastDueOpp model returns no rows because (I think) the Condition is still active and is filtering where its market__c field is null.  Since it is a required field… it returns no rows…  My desired state would be either to not allow the user to uncheck all or to deactivate the condition if they do.


Right.

So, make the first action of your action sequence that runs when MARKET_UI is updated “Run a skuid javascript snippet”

Here’s your snippet:


var model = argumentsu0].model,<br>row = argumentsu0].row,<br>returnVal = false;<br>if (model.getFieldValue(row,'MARKET__UI')) {returnVal = true'}<br>return returnVal;

Then, add these two actions in the “error sequence” of that snippet in the action framework:

  • deactivate model condition

  • query model


Your full action framework should look something like this:


1. Run snippet
---- ! 1. Deactivate Condition
---- ! 2. Query Model
2. Activate and Set Value
3. Query Model


Got to Work!  I had to use this syntax though…


var model = skuid.$M('UI_ONLY_ForFilters'),<br>row = model.getFirstRow(),<br>returnVal = false;<br>if (model.getFieldValue(row,'MARKET__UI')) {returnVal = true}<br>return returnVal;<br><br>Thank you!<br>





Glad you got it working!


Reply