Copy all list items to another daily - query items updated?


Badge +3

I am creating a 'version' list to create trend data (I do not have access to a sql db at this time).  To do the versions, I am copying all list items to a 'version' list every day at the same time but the workflow takes several hours to complete.  I would like the copy to be the status of all items at the time the workflow starts - will the query list bring all items into the workflow or does it reach out again to the live list when looping thru and therefore possibly get an updated version?


19 replies

Userlevel 5
Badge +13

@btorres7 If the query list is outside the loop, all the data should be in the collection at time of action execution. If you have queries in a loop they would be executed each time through the loop and would be getting new data. 

Badge +3

Thank-you!   That's all I needed to verify.

Unless you know of a quicker way to copy over items...?

Badge +3

Actually - I just checked a running workflow that started early this morning: an item that was copied over that had been edited after noon copied over with the updates done to it - not as it was when the workflow started.

I am doing a query and then looping thru the collection to copy the item to the version list.

8446i19AE7E8101677BF6.png

Any way to prevent that?

Userlevel 5
Badge +13

@btorres7 The copy item action is running on each loop which is why the data is changing. If you wanted the data to be set at the initial query you would need to store all the columns as part of the initial query and create/update item rather than copy inside the loop.

Badge +3

@leighburke So make a collection for each column?  There are quite a number of columns. If I did, how do you make sure you are putting the correct collection items together when creating the item?

 

8449iA536D64A49912C33.png

 

Userlevel 5
Badge +13

@btorres7 The collections should all be added in the same order, so long as you use the same index in your collection actions it will all be referencing the same row.

 

 

Badge +3

@leighburke   So sorry but could you show me how you use the collection(s) to create the item with all the fields. (I see - it is a lookup field that I am trying to set....- on another site...)

Userlevel 5
Badge +13

@btorres7 You have your for each loop setup for one of your collections. Each other collection has get item from collection setup(https://help.nintex.com/en-US/nintex2016/current/#sp2016/zz-update/Workflow/ActionsCore/CollectionOperation.htm), which will store the item from the same row in a variable. After you have pulled item from each collection, you use these variables in your create item action like below.

 

8455i98BAFEAEB5F77A2C.png

 

 

Badge +3

@leighburke   I got that - just have an issue now with the lookup fields to lists on another site (used site columns to create them - the workflow is on a subsite).

Userlevel 5
Badge +13

@btorres7 Do you have any example of the issue you are seeing, you should be able to set the value of lookups using variables as well.

Badge +3

@leighburke   Here is what I see:  on some of the lookup fields to lists that are in another site, I do not get the option of setting the value any variable.  The State and Country lookups to lists on the same 'other' site work while another to States doesn't.  ?

 

8466iB2ED51A4A5F19077.png

 

I have text fields for these lookups that I was thinking I could put as their values but that is not working either.  Some of the lookups do not let me set them to a variable of any sort.

 

Badge +3

@leighburke Do I use a 'Retrieve data' from the lookup collection variable and set it to a number variable for this instance?  Then use that to set the 'value'?

8467i5480A70E1B03AD3D.png

 

Badge +3

@leighburke   I have around a hundred columns - there has to be a better way!

Userlevel 5
Badge +13

@btorres7  The left hand side should also be a drop down that allows you select workflow data. I am not aware of a better method if you want to get the data at time of workflow trigger. You could potentially use one of the SharePoint web services but I have not seen this done.

8469i88BBB26478AB3034.png

 

Badge +3

It is just frustrating that copy works so well (except for the timing) and create has the setting fields issue:  I am trying to set lookup field values and it has issues when they are blank (I think).  Do I set them equal to the ID values or to the string values?

Badge +3

@leighburke   I am getting an error:  after Create Item and then a Math Operation to increase the index of a loop.   Why am I getting this error when there is no 'update' in my workflow?

The workflow could not update the item, possibly because one or more columns for the item require a different type of information.

Userlevel 5
Badge +13

@btorres7 Lookup fields will be expecting the ID, so an integer data type if you are using a variable. If you need to get the lookup id as part of a query list you can edit the caml and add the following(LookupId="TRUE")  as below.

 

8471i241F196EE2BF2FB7.png

 

Badge +3

@leighburke  I keep getting the same error - I updated to just get the ID (though I had added the ID field to the lookups and was working it that way).   I gets thru everything but when it goes to loop - it has the issue and if it is a field issue, it does not tell me what field.  What's weird it that it does not show any of the 'log in history list' results.

8488i8FFF741642939276.png

 

8489iC9738FCA9EFD6CDF.png

 

 

Userlevel 5
Badge +13

@btorres7  You could check your variables that are being used in the  item action are correct data type. If you need more detail on the error you would need to reach out the support team(support@nintex.com) and provide logs.

Reply