More multiple-choice fun: Reading one multi-select and making choices on a second multi-select | Community
Skip to main content
JohnJOSullivan
Level 5
May 30, 2023
Solved

More multiple-choice fun: Reading one multi-select and making choices on a second multi-select

  • May 30, 2023
  • 1 reply
  • 1450 views

It was supposed to be so easy. And I'm sure it's possible to do this. The particulars are what's irritating. My hope is that I post this and then figure it out tomorrow morning while on my jog. 😄

 

Here's the ask:

A group wants to read a multi-select field on an issue. From that, Fusion would read the choices and map them to another multi-select field.

  • If choice is A, B, or C on first field, it choses 1 on the second.
  • If choice is D on first, field, 2 on the second
  • If choice is E or F on first, 3 on the second

Considering it's multi-select, if the choices were A and E on the first field, Fusion would chose 1 and 3 on the second field. 

I know we're dealing with an array because we're dealing with a multiselect, so I try iterating out all the choices. Then, I set a variable using an IF statement...

...

And I don't know how to aggregate those choices by Issue so I can set the choices on the second field.

I'm almost certain that we have an example of something similar in one of our scenarios but I can't find it.

This has to be easy and has to be a relatively straightforward and common use of Fusion but I'll be dang darned if I could figure it out between meetings. 

 

Any hints would be greatly appreciated and would be credited to you as a free drink if I ever run into you at a Workfront event. 😄

 

Thanks!

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by ChrisStephens

John

First, I'll cover how I would tackle this, then I'll cover where it's going to get sticky.

Process

  1. Combine all of the multiselect fields into a single array using the merge function, so it looks something like combinedArray=merge({multiselect_1};{multiselect_2};{multiselect_3}
  2. Then, for each of the target properties, I would do updateArray=remove(add({{emptyarray}};if(contains(combinedArray;option_1);property_2_option_1;{{emptystring}}...[repeating for each option]);{{emptystring}}). This will end up with the array you need to update your secondary objects, and repeat for each secondary field/object

Where it's going to get sticky is with a fun quirk of Workfront. If only a single object is checked on a multiselect, it comes in as a simple string, and not an array, but the merge function only works on an array. So what you end up having to do is check to see if the value provided is a string or an array, and if it's an array, then huzzah, nothing further required. If it's a string, then you have to convert it to an array, then pass it into the merge.

1 reply

ChrisStephens
Community Advisor
ChrisStephensCommunity AdvisorAccepted solution
Community Advisor
May 31, 2023

John

First, I'll cover how I would tackle this, then I'll cover where it's going to get sticky.

Process

  1. Combine all of the multiselect fields into a single array using the merge function, so it looks something like combinedArray=merge({multiselect_1};{multiselect_2};{multiselect_3}
  2. Then, for each of the target properties, I would do updateArray=remove(add({{emptyarray}};if(contains(combinedArray;option_1);property_2_option_1;{{emptystring}}...[repeating for each option]);{{emptystring}}). This will end up with the array you need to update your secondary objects, and repeat for each secondary field/object

Where it's going to get sticky is with a fun quirk of Workfront. If only a single object is checked on a multiselect, it comes in as a simple string, and not an array, but the merge function only works on an array. So what you end up having to do is check to see if the value provided is a string or an array, and if it's an array, then huzzah, nothing further required. If it's a string, then you have to convert it to an array, then pass it into the merge.

June 19, 2024

Hi @chrisstephens  

 

I know that this is an old post but I am facing the same issue with my Fusion scenario now. I am able to set variable by using the merge expression to combine the multi select fields. Everything works fine until someone chose a single value on those multi select fields. Are you able to explain further how can we check if the value provided is a string or an array and how to convert them to an array? Is there a way to make sure that the fields are put as arrays no matter if they are filled with multi or single values?

 

Your help is greatly appreciated. Thank you!!