Christopher-b
Scholar

Adding variables to List using Create Item

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

 

 

0 Kudos
Reply
10 Replies
Aleximo
Contributor

Re: Adding variables to List using Create Item

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-s...

 

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

 

without screenshots is pretty difficult to find the error.

0 Kudos
Reply
Christopher-b
Scholar

Re: Adding variables to List using Create Item

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

 

0 Kudos
Reply
Aleximo
Contributor

Re: Adding variables to List using Create Item

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 :).

0 Kudos
Reply
Christopher-b
Scholar

Re: Adding variables to List using Create Item

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

0 Kudos
Reply
Aleximo
Contributor

Re: Adding variables to List using Create Item

@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):

 

Aleximo_0-1643734527265.png

 

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

 

Aleximo_2-1643734612619.png

 

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.

 

Aleximo_4-1643734766436.png

 

 

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

 

Aleximo_6-1643735065238.png

 

 

ur workflow should look like this:

 

Aleximo_5-1643735045891.png

 

 

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:

 

Aleximo_7-1643735234825.png

 

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

 

Aleximo_8-1643735315462.png

 

the final workflow should look like this:

 

Aleximo_9-1643735393322.png

let me know if u have any questions 🙂

0 Kudos
Reply
Christopher-b
Scholar

Re: Adding variables to List using Create Item

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

 

 

0 Kudos
Reply
Aleximo
Contributor

Re: Adding variables to List using Create Item

hey chris @Christopher-b ,

 

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

 

Aleximo_1-1643872640082.png

 

the RIGHT SIDE one should look like this:

 

Aleximo_2-1643872682036.png

 

the LEFT SIDE one like this:

 

Aleximo_3-1643872726531.png

 

is it set up like this?

0 Kudos
Reply
Christopher-b
Scholar

Re: Adding variables to List using Create Item

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

0 Kudos
Reply
Christopher-b
Scholar

Re: Adding variables to List using Create Item

Hi @Aleximo ,

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

Screen Shot 2022-02-03 at 11.46.32 PM.png

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

 

0 Kudos
Reply