Model Condition Field in other model Multi-picklist field??

  • 1
  • Question
  • Updated 3 years ago
Added a Multi-Picklist field to the SF User object for "Country__c" which the user works/handles.

- I made a RunningUser model like suggested in other conversations, that pulls the current user and the Country__c field fine. 

- Trying to add a condition to another model to restrict records to the countries selected in the users Country__c field, as below.

Comparing a Single item picklist to a multi-picklist.

Works fine if the RunningUser Country__c has one value selected.  If I select multiple, the condition always fails. (All objects get filtered out)


With multiple countries selected, the model and queue is empty:


With just one, the model loads and the queue displays:


As a test, I made the model condition on a hard-coded set of values and that works fine with single or multiple:


What am I missing?

Thanks
Seth
Photo of Seth Vanderdrift

Seth Vanderdrift

  • 878 Points 500 badge 2x thumb

Posted 3 years ago

  • 1
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
I think the problem is that multipicklist fields get passed as a single semicolon separated string ("Haiti;DR") and the 'field from another model' condition isn't parsing them correctly.

Not sure what to do about that, but diagnosis is the first step to healing!
Photo of Seth Vanderdrift

Seth Vanderdrift

  • 878 Points 500 badge 2x thumb
Thanks. 

 At present it looks like I need a way to reverse the query to be :
(RunningUser)(M2Country__c) contains Country__c
Photo of Matt Sones

Matt Sones, Champion

  • 31,478 Points 20k badge 2x thumb
Perhaps a "result of a subquery" condition would work here?
Photo of Seth Vanderdrift

Seth Vanderdrift

  • 878 Points 500 badge 2x thumb
Looked in to subquerys, but couldn't see a simle way (any way actually) to use them.

Seems like the long-term Skuid power user way would be the option to manually enter the the condition arbitrary text.

So I punted and added formula fields based on this:
https://success.salesforce.com/answers?id=90630000000gv5cAAA  (After reading this and http://cloud4good.com/announcements/evils-multi-select-picklists-salesforce/ , I going to consider multi-picklist fields more carefully.

Our multi pick only has 2 values, so it's annoying but I made two forumla fields, one for each country which returns the country name if it's in the multipick list.

I have the text formula fields with this formula:
IF( INCLUDES( M2Country__c , "Haiti") , "Haiti", null)

Seth
Photo of David Giger

David Giger

  • 1,758 Points 1k badge 2x thumb
Seth,

I figured it out how to do this.

What you need on the model where you want to filter by country, you add a condition for the country-picklist field which contains multiple values (leave them empty) and filterable default off and not loading data on page load.
Also make sure to have a condition on the model where you get only the records belonging to the appropriate school.



You then add an in-line snippet (in your case a snippet on-click of the queue item) as follows (you will have to alter the snippet slightly: replace model_one.data[0] with your context row of the clicked queue item):
var model_one = skuid.model.getModel('school_model');
		var model_two = skuid.model.getModel('user_model');
        model_two.setCondition(model_two.getConditionByName("country"), model_one.data[0].country__c.split(";"));
        model_two.activateCondition(model_two.getConditionByName("country"));
        model_two.updateData();
You need to split up the country string (its a semicolon separated string using the javascript .split("delimiter") method) and add it to the condition value (there is no need to assemble the string again).

I hope this helps you

Regards