Skip to main content

Nintex Forms for NWC was just released yesterday, and just in time for me to add a contact form to my new website (https://www.docfluix.com).  Matt Jennings‌ already posted an awesome intro for Nintex Forms for NWC so check this out to understand what this awesome new product is all about.

 

Background Info

My goal for my first Nintex Forms for NWC project was to create a simple web contact form (Name, Company, Phone, Email) and save the data to a SharePoint list. I also decided to add a multi-choice control named CustomerInterest to my form with the following options:

  • Workflow / Business Process Automation
  • Document Management (ECM / Records Management)
  • Collaboration
  • Intranet / Portals
  • Migration to SharePoint
  • SharePoint Governance
  • SharePoint Adoption

 

In my SharePoint site, I added an out of the box Contacts list, and customized it with a choice field (also named "CustomerInterest") that allows multiple choices and includes the identical options above.

 

After the Start Event, I added the SharePoint Online action Create an Item to my workflow and connected it to my site.

 

This action displays the columns from my new SharePoint contact list including the CustomerInterest field.  Initially, my plan was to directly map the CustomerInterest collection variable to the CustomInterest SharePoint column. However, that approach does not work.  The solution however, is quite easy but not totally obvious...

 

To understand the solution, please note the following:

  • When you define a Multiple Choice field in Nintex Forms for NWC, it creates a variable for that control of type collection.  This collection shall be populated with only the choices that the user selected.
  • If you want to populate a multi-choice column in SharePoint, you need to pass it a concatenated string of all values separated with ;# (semi-colon hashtag).  So I would need to export a string that looks like this: "Collaboration;#SharePoint Governance;#SharePoint Adoption"
  • In Nintex Forms for NWC, the title that is displayed for each control becomes the name of the start event variable created in the workflow.  So in my form, the multi choice field is titled as "Are you looking for assistance with:", and so that is also the name of the collection variable that I will reference in my workflow.

 

Solution

The solution is to iterate through the collection variable and format a text variable the way SharePoint expects for a Multi choice column.  Although this part is quite simple, I'll outline my steps:

  1. Define new variables:
    • CustomerInterests (Text) - Will store the concatenated value to map to the SharePoint choice column
    • ChoiceItem (Text) - Will store each selected choice from the collection variable
    • Idx (Integer) - Used for loop processing 
  2. Add a Loop For Each action configured as follows:
    • Target Collection: Are you looking for assistance with:
    • Store Item: ChoiceItem
    • Index: Idx
  3. Within the Loop For Each action I added
    • A Get Item from Collection action
      • Target Collection: Are you looking for assistance with:
      • Index: Idx
      • Store Item: ChoiceItem
    • A Set a variable value action (optionally, the Create a text string action would also work the same way)
      • Variable: CustomerInterests
      • Value: eCustomerInterests] ChoiceItem];# (this concatenates the next ChoiceItem to the end of the string for each iteration)
  4. In the Create an Item action, now I was able to simply assign the CustomerInterests text variable to the CustomerInterest SharePoint column.  When this action executes we end up with a new list item in SharePoint with the intended choices selected.

 

Here is what my completed form looks like:

207813_pastedImage_27.png

Hey Tom,

This post saved me a bit of time!

I reckon you can remove the Get Item from Collection action though and it should still achieve the same result as the item is already being saved in the loop action.

Cheers,

Chris


Hopefully Nintex will add a function into NWC to make this common activity even easier. For a company that claims we should be using "clicks, not code", this is awfull lot like writing code.


Reply