Copying Data from one list to another with different columns

  • 12 October 2022
  • 5 replies
  • 243 views

Hi there, 

I would love some help with this! My company has Nintex 2019. I would love to copy data from List A (this is more of a working list with many people on it) to a List B (that we store completed data for a while and it does not change). I would like to use a workflow to move this data. List A has has more columns then List B as we don't need all columns in List B. What is the best ways to do this? As a bonus, once the data is moved to List B, it is no longer needed on List A, so it can be deleted/removed.

Thanks for your help!


5 replies

Badge +2

You should be able to do this with at least the Create Item action, and maybe the Delete Item and Update Item actions would be helpful too. This should be a list workflow, but you could consider a site workflow on a schedule also if it makes more sense for your needs.


 


If items are updated by users in the first list after having been created, you will need an identifier to update the equivalent list item in the second list. (If you don't already have a unique identifier, I would use the SP ID from the first list as an identifier.)


 


I would also recommend using the Query List action to make sure the second list item isn't already created before creating it. Likewise, I would use another Query List to confirm the item is in the second list before deleting the equivalent list item in the first list.

Thanks so much for this information! I tried it and it worked on a one-to-one basis. I made a site workflow: query list->create item-> delete item. However, it would only do it one item at a time. I would love it to look for all the items that match the query list filter and run it through the flow. I am assuming I may need to use a collection variable and for each loop or collection? I haven't used either before so not totally sure how to use them. Thanks for the help!

Badge +2

Yes, you will need to use at least one collection or more depending on how you do it. There are two ways I do this and you should choose based on what you're more comfortable with and what works best for your data.


 


One way is to query list and have that result in a unique identifier being put into a collection variable. Then use For Each to loop through each unique identifier in the collection. Inside the loop, use the unique identifier to Query List again for the rest of the columns that you need. Then use Create Item, Update Item, and Delete Items as needed to maintain the data in the second list.


 


Another way is to have the first Query List populate multiple collection variables, one for each data column that you need. Then you can use For Each to loop and use Collection Operations to get the values from the collections. You will need an integer index that you increment every time through the loop to know which collection item to get. Then use Create Item, Update Item, and Delete Items as before. I find this second way slightly more complicated, but it is also probably more efficient because there is only one Query List needed.

Thank you so much! I managed to try and get the first one going (almost!). I can see the workflow runs, but does not "complete" as I get this error: "Coercion Failed: Unable to transform the input lookup data into the requested type." I can see that the data does move and is deleted. So it works but gives an error. I would love to make sure it truly does work without this error!


Here is the overview of my workflow:


 



This is the first query, where I find the IDs and put them into collection variable:



This is my for each loop, where I put the collection output into a collection variable: 



This is my second query, where I am looking back at the original data to get the rest of the info I need and for my create item columns. I am wondering if how I am filtering this action item is causing the error? Basically I am trying to make sure that the original query that found the unique ids (which are sitting in the output text variable) filters to the specific id in the the same data set to find the rest of the item information I want to copy to my new list. 



I then create a item in the new list and delete the old item from the first list. I have tried it three times and it works (creates the items and deletes them), but I always get this error. Thanks for your insight and help so far too!

Badge +2

The coercion error means to me that one data type is interacting with a different data type that doesn't correspond. It's possible that the ID doesn't like being compared to the text_output variable if the ID is type List Item ID and the text_output variable is text or a collection. I would use Log to History actions around suspected actions in order to determine which action is causing the error. 

Reply