Adding variables to List using Create Item

  • 28 January 2022
  • 10 replies
  • 144 views

Hi –

 

I am using Nintex with SharePoint 2019.

 

I created a repeating section in a list “Weekly Status Update” and placed five controls in it:

 

Major Accomplishments – MLT

Week Ending – Date

Team – Choice

Category – Choice

Priority – Choice

 

I have been able to use Query XML to parse the data and add each control to individual Collections.

 

For instance, I have: colMajorAccomplish, colWeekEnding, colTeam, colCategory, colPriority.

 

I created a For each loop and stored the Collections into variables. I have: varMajorAccomplish, varWeekEnding, varTeam, varCategory, varPriority. I also have an index configured for each collection.

 

I have a Math operation that loops through the variables.

 

I have created a separate list called “Weekly Report.”

 

Each of the collections has a “Create item” to add variable content to the “Report” list.

 

Where I’m stuck: The workflow runs, but it does not add all of the collection items to a single list item. If I do a save in my form, it will add a separate row/index for every collection. So, if I save one repeating section with the 5 controls, my list looks like:

 

Major Accomplishment

 

 

 

 

 

Team

 

 

 

 

 

 

Priority

 

 

 

Category

 

 

 

 

 

 

WeekEnding

 

 

I’ve seen a number of solutions for getting things out of repeating sections and some on how to add to a list, but nothing for SharePoint or that explains how to add variables to one item / row.

 

Unfortunately, I have no good way to share my screen shots. Working in two separate environments.

 

Thanks,

Chris

 

 


10 replies

Badge +8

hey @Christopher-b ,


 


have a look at this post: https://community.nintex.com/t5/Nintex-for-SharePoint-Forum/Query-XML-for-Repeating-Section-how-to-set-up-correctly/td-p/214265


 


could u compare ur workflow to his? maybe that will help u.


 


without screenshots is pretty difficult to find the error.

Hi @Aleximo ,


After some changes and looking at suggestions, I was able to get my workflow to create items in a list. However, I am unable to update the original item.


 


If I create an item, it creates the item in the list. If I go back to the list form and Edit that item, it creates another item/row. So if I create one item, but go back and edit it 3 times, I will have 4 separate items in my list, not just 1 item, which is the desired result.


 


Is there a way for my workflow to look at the ID field when I edit an item and write over that ID and NOT create a subsequent ID?


 


Unfortunately, I don't have a good way to export a screen shot as my workstation is isolated with no external access.


 


Thanks,


Chris


 

Badge +8

hey @Christopher-b ,


 


before I write a long solution for updating the items... wouldnt it be okay to delete the extisting items and recreate them? that would be a lot easier 🙂.

Hi @Aleximo 


Yes, that sounds easier, but unfortunately, will not work for this use. There will be a few people making edits / changes, so deleting them does not really work.


 


I'm not sure what to search for on this issue. It sounds like I should be able to use Edit item, but I'm not sure how to add that to the WF. 


 


Thank you for your help / suggestions.


Chris

Badge +8

@Christopher-b


 


okay... ur workflow works creating the items in the "Weekly Report" list.


 


u need to add in the "create element" another field that has to be set to the ID value of the current item (in my example i took the title field):


 



 


So in the other list it has to look like this (u can just create a textfield and hide it in the view):


 



 


so... now u have to create the "update" part of the workflow... for this u have to create a "lookup in list" after the xml query:


 


u have to configure it like that:


 


choose the list "Weekly Report"


 


then filter it only when "Title" (here u have to enter the textfield that u create to set it to the ID...I will call it "Title" for symplicity ) equals the ID from the current element


 


then choose the ID field and "Title".


 


set the ID value into a collection variable -- collIDs f.e.


 


set the "Title" value into a Text var "varAnyItemsYet" f.e.


 



 


 


now u need to check if "varAnyItemsYet" is empty or not (that way the workflows knows when to create and when to update items):


 



 


 


ur workflow should look like this:


 



 


 


now the easy part... copy ur existing workflow elements to the other site of the condition and delete the "create element" on the left side:


 


create a number var "currentID" and then u have to configure the "for each" like this (varIndex is the same as the number variable u used in the for each on the right side:


 



 


at the end u have to put a "update item" and set it up like that:


 



 


the final workflow should look like this:


 



let me know if u have any questions 🙂

Hi @Aleximo ,


 


I guess I'm still missing something. I followed you instructions and rebuilt my WF from scratch (started over). Now, it does not add any if the items to my Weekly Report. 


 


The WF is attached to a list called Weekly Status. The only column I have in that list is my "repeatingSection." This is where I have placed MajorAccomplishments, Team, Category, etc.


 


I created all of those columns in the Weekly Report list. In addition to the new "ID" field assigned to "Title."


I placed some "Log in history list" at several places. After "Query XML Major Accomplishments," it logs all of the collection variables. Placing login any further down, and nothing shows up in the history log. 


 


Here is what I have now:


 


I think the issue has something to do with where or how I have ID defined.


 


Thank you so much again for your help.


Chris


 


 

Badge +8

hey chris @Christopher-b ,


 


the only thing i noticed is that u might have both "for each" set up identically.


 



 


the RIGHT SIDE one should look like this:


 



 


the LEFT SIDE one like this:


 



 


is it set up like this?

Hi @Aleximo ,


 


It was not, but it is now. I still don't get any output to the list. After making that change, I am getting, "Error operating on collection variable. Index property is greater than the number of items in the collection."


 


When I log "List ID" and "varIndex." they increment for each addition or edit. For example:


ListID = 13


varIndex = 130


edit or add item


ListID = 14


varIndex = 140


edit or add item


ListID = 15


varIndex = 150


 


I've gone through all of the settings and verified they are as you suggested. 


 


I'll continue to read through solutions in community. Let me know if you have any additional suggestions to check.


 


Thank you.


Chris

Hi @Aleximo ,


I believe that what is happening is that I am unable to add "Value=ID" that you have in your explanation.



In my "Create Item," if I select "Value" I don't have any options. I have to type in a value. Looked at using "List Lookup," but this does not give me the ID value like your description either.


 


Any idea why when I select "Value," I don't have the option to get "ID?"


 


Thank you.


Chris


 

Badge +8

hey chris @Christopher-b ,


 


in ur pic9 u had the value set to "ID"?


 


the ID is a sharepoint generated field that provides every item a unique number... u need that number to identify the items in ur other list.


 


i just set it up like this:


 



 


if thats not working u could try following:


 


take "lookup in list" --- "current item" --- "ID"


 



 


both ways work for me.


 


and just to calrify... i've made the same workflow and it works just fine. 🙂

Reply