Expand my Community achievements bar.

Latest Community Ideas Review is Out: Discover What’s New and What to Expect!
SOLVED

How do i us the deDuplicate array function in fusion

Avatar

Level 3

I have some fusion processes where, under certain conditions, multiple Role IDs for the Project Manager (PM) are being added to specific tasks. I’ve tried various approaches, but I haven’t been able to successfully deduplicate the Task RoleID field to prevent duplicate roles from appearing. I cannot get he deDuplicte function to work.

Any advice or guidance on how I can address this would be greatly appreciated!

 

JohnMi_0-1729123436279.png

 

Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Level 6

Hi @johnmi11 @JohnMi 

  1. The reason to use a generic "fusion user" instead of a persona account is that it is tied to your user ID. When you're no longer on this project, the client may remove your account - and the scenario will fail. 
  2. I don't get this: "Not sure why I would assign a ROLE that no USER is assigned to" - I wasn't suggesting that. But regardless: Your client is asking to assign roles based on a custom form (otherwise you could set them at the template). Two potential issues for the error:
    • The multi-select field is required so it'll always have a value. However, if a single role is checked, that value is a string; if 2 or more are checked, it's an array. In those cases I us a setVar to make sure that I always have an array to work with. If the toString of the variable is not itself, then I already have an array; otherwise I need to add it to an empty array
      SveniX_0-1730131322809.png
    • The assignMultiple action in the MiscActions module throws an error if you don't select a user for the assignment. Apparently it doesn't like a null here. Instead, map it to an empty array, then the roles assignment will work. 
      SveniX_1-1730131455593.png

       

I've tested this in Fusion - the assignment works whether one or more options in the custom form are checked. Let me know!

View solution in original post

7 Replies

Avatar

Level 10

Hi John,

 

as you already wrote, deduplicate() is an array function. 

In your setup, you are trying to deduplicate the field roleID, which stores a single value only. So this will not work as expected.

You are probably wondering why the field only saves a single value when it is possible to assign several roles to a task.

 

As I understand it so far, there is a historical reason for this. The option of ‘multiple assignments’ has probably not been around for that long.

 

So today, assignments are stored into a different database table and connected to the task as a collection.(https://developer.adobe.com/workfront/api-explorer/)

 

 

Back to your issue: I am not really sure, if you will be able to find an easy solution, but perhaps I did not really get the point.

As roles are objects in Workfront as well, they all have an unique ID. I am quite sure, that it does not happen, that an ID is assigned multiple times to the same task. 

So, I suggest, that you have different job roles with the similar name...? As each role object has a different ID, the deduplicate() function would be of no use anyway. Finding a solution here could be quite a bit more difficult, as you would need different steps.

But before going into detail (not tested), I need to understand the issue better.

 

 

Regards

Lars

Avatar

Level 1

Thanks @lgaertner 

 

I’ve decided to take a different approach since there doesn’t seem to be a clear solution for my issue. The challenge I’m facing is that I need to assign up to 5 different roles to a single task, as per my client’s request. These roles are selected via a multi-select custom form field, and the value for each is a ROLE ID.

 

The issue is that the module won’t allow me to write logic that adds either the ROLE ID or a null value without triggering an error. I tried creating an IF statement to pull in the ROLE ID where applicable and insert a default value if it wasn’t selected, thinking I could deduplicate the results later. However, the deduplication function didn’t work as expected.

I’ve attached a screenshot below for reference.

 

johnmi11_0-1729778193746.png

 

Avatar

Level 6

Hi @JohnMi 

 

in your module you SET values. You can't "deduplicate" here against the already-assigned roles. 

 

In addition: If role X is already assigned and you again assign role X - WF is smart enough to handle that so there's really no need to de-duplicate. 

 

Comments

- you shouldn't use your personal WF account to do Fusion calls; instead, create a Fusion User

- you shouldn't assign the ROLE of a USER to a task. Either you assign a role (but why: You should be doing that in the template), or you assign a user based on his/her role.

 

Can you maybe explain more about exactly what the flow/logic is you're trying to implement in this scenario? 

 

BTW: to do assignments there's a nifty assignMultiple action in the MiscActions module:

miscAction-assignMultiple.png

 

 

 

 

Avatar

Level 1

@Sven-iX Thanks!

 

In regards to your Comments"

"- you shouldn't use your personal WF account to do Fusion calls; instead, create a Fusion User" - Not sure why this is the case, regardless I do not have a choice or say regarding that since it is my client's instance. If there is a documented reason, please let me know so maybe I can make the request.

"- you shouldn't assign the ROLE of a USER to a task. Either you assign a role (but why: You should be doing that in the template), or you assign a user based on his/her role." I do not understand. ROLES are ROLES and you create ROLES and apply them to USERS. Not sure why I would assign a ROLE that no USER is assigned to.

Avatar

Correct answer by
Level 6

Hi @johnmi11 @JohnMi 

  1. The reason to use a generic "fusion user" instead of a persona account is that it is tied to your user ID. When you're no longer on this project, the client may remove your account - and the scenario will fail. 
  2. I don't get this: "Not sure why I would assign a ROLE that no USER is assigned to" - I wasn't suggesting that. But regardless: Your client is asking to assign roles based on a custom form (otherwise you could set them at the template). Two potential issues for the error:
    • The multi-select field is required so it'll always have a value. However, if a single role is checked, that value is a string; if 2 or more are checked, it's an array. In those cases I us a setVar to make sure that I always have an array to work with. If the toString of the variable is not itself, then I already have an array; otherwise I need to add it to an empty array
      SveniX_0-1730131322809.png
    • The assignMultiple action in the MiscActions module throws an error if you don't select a user for the assignment. Apparently it doesn't like a null here. Instead, map it to an empty array, then the roles assignment will work. 
      SveniX_1-1730131455593.png

       

I've tested this in Fusion - the assignment works whether one or more options in the custom form are checked. Let me know!

Avatar

Level 6

Hey @JohnMi 
I just noticed that if you were to assign users and leave roles blank - it also wants' an emptyarray in roles