Script Error - Spawn and Add Task

Script Error - Spawn and Add Task

pxedust
Contributor Contributor
711 Views
3 Replies
Message 1 of 4

Script Error - Spawn and Add Task

pxedust
Contributor
Contributor

Hi all, 

 

I'm trying to deploy working code from my SB to prod and am getting the following: 

 

com.dms.model.exceptions.InvalidFieldValueException: Can only convert MultiselectWrappers and NativeArrays to Multiselect fields

 

I've verified that everything matches up between the 2 tenants, so I'm struggling to figure out why it works on one side and not the other. The action script is straightforward: 

 

pxedust_0-1623118050620.png

and the library script relatively so: 

 

pxedust_1-1623118234367.png

 

I've found and fixed a few blunders (including forgetting to update the DMSIDs to the production records), but they've not done the trick. I assume it's tied to getting the assigned users to populate, which match between the 2 tenants. I have another array issue on another project (trying to spawn a clone, but one issue at a time), so the error is doubly frustrating. Any idea what I'm overlooking? 

 

0 Likes
Accepted solutions (2)
712 Views
3 Replies
Replies (3)
Message 2 of 4

sven.dickmans
Autodesk
Autodesk
Accepted solution

I guess the error is thrown by this line:

spawnedTask.ASSIGNED_USERS = spawnedTask.APPROVAL_ROLE.USERS_ASSIGNED_TO_ROLE;

 

Do the definitions of fields ASSIGNED_USERS and USERS_ASSIGNED_TO_ROLE match? I assume that both are users picklists, right?

 

You may have to loop the list and add given entries:

if(spawnedTask.APPROVAL_ROLE !== null) {

for(var i = 0; i < spawnedTask.APPROVAL_ROLE.USERS_ASSIGNED_TO_ROLE.length; i++) spawnedTask.ASSIGNED_USERS.add(spawnedTask.APPROVAL_ROLE.USERS_ASSIGNED_TO_ROLE[i]);

}

 

Additional remark: You do not need to pass 'item' to your library script function as the function has access to this global element anyway

 

 

Message 3 of 4

philipfrench
Collaborator
Collaborator
Accepted solution

Further to Sven's comment... also check that the picklists have the same setting for multi- or single-select (check the radio buttons on the field definition).

I think that error comes from confusing between an array (picklist multi select) and a non-array value (picklist single select).

Message 4 of 4

pxedust
Contributor
Contributor

Thank you!!!

 

I went through everything (ha!) at least twice again last night, and found I'd missed this: 

 

pxedust_0-1623169756292.png

There's already a field with and ID of ASSIGNED_CHANGE_ROLES, so I opted to recreate the mismatch in production. Success and some very, very dorky chair dancing resulted. 

 

Re: the passed item, I'd noticed that in the documentation but until I had everything moved over I wasn't inclined to mess with script that (in the sandbox anyway!) was working until I'd verified that the move worked. I appreciate the confirmation!

 

Huge thanks to both you and @philipfrench. I'm starting to get into our scripts and doing development on other projects in earnest, the assistance is invaluable!

0 Likes