Skip to main content

I am pretty sure this is not possible, but I thought I'd as you experts.  

 

Is it possible to get workflow (and/or Smartform rules) to write something like this in a memo field on a smart form as separate records onto a database table using the 'create' SmartObject method?  I'd like the end user to be able to copy/paste a list of document control numbers either from an e-mail or a spreadsheet into the field, and then click "Save" or something and have the list of items get written as individual work item records in the database.  

 

I've experimented with Create Reference and For Each, but can't get it to work.  

 

Any thoughts?

 

Rob

 

11876i7605CC99910DBD2B.jpg

I have not tried it with purely SmartForms, but it does seem possible with a workflow; however, there may need to be additional considerations in validating the data to ensure that it covers most use cases and user errors.


 


This works because the foreach loop will accept a semi-colon delimited list:


https://help.k2.com/onlinehelp/K2smartforms/UserGuide/4.7/default.htm#Thin_Client_Wizards/General_Wizards/For_Each/For_Each.htm?Highlight="Semi-colon%20delimited%20text"


 


Such that:


1231231


4342342


3423424


 


Can be manipulated to:


1231231;4342342;3423424


 


And then passed into the ForEach loop.


 


1.  Pass this (newline separated list?) memo control into a data field on workflow start:



 


2.  Add a Set Data Fields to manipulate this Data field so that it becomes semi-colon separated list:



 


3.  Having this as a separate set data fields event will allow auditing of the data to see if there are any issues in the Viewflow:



* entries separated by newline are converted to semicolon list


* you can also use a totally seperate data field if you wish to preserve the initial values


 


4.  This is done so with URLDecode(Replace(URLEncode(DataField),%0a,;))



* This is essentially URLEncoding the data field which changes the newline characters to "%0a", allowing us to use a replace function to replace "%0a" with ";", and then encoding the data again for good measure


 


5.  Then in the ForEach loop, pass it this data field which is now 'semi-colon' delimited:



* Give it a reference name and index name; the reference here would be a reference to a single item (not the collection)


* I used an email event here, but if you can swap that with a SmartObject call in your use case


 


1.  Some things we will likely need to consider are:


 


a.  Does copying from Excel or other applications resulting in a newline separated encoding (I only tested with typing into the memo control and hitting the "Enter" key to create newline);


 


b.  What happens if there is leading/trailing spaces or newline characters, hidden characters?  Perhaps including some additional "Trim" line function and validation on the form and workflow


 


c.  What happen if two newline exists, does it create a blank entry?


 


You rock!  

 

I think this will work perfectly.  Going to try it today.

 

Rob

 

 


Reply