Skip to main content


 

Symptoms

 


Sometimes, the length of the email is too big i.e. more than 255 characters limit of single line of text in SharePoint list (this is a business requirement) and throws error when try to save it in list item. Email addresses are returned as a semi-colon delimited list. Now, I have to truncate the characters after 255 and save the email ID string in list item, but when I truncate the string using the expression there is high probability that last emails may also get truncated and we have to avoid including the last email if it is not fitting in 255 limit. Hence I want to save maximum COMPLETE email IDs that will fit within 255 characters.
 

 

Diagnoses

 


It appears that the current SmartForms Function andgt Operators available may not be enough to accomplish what you are attempting as such, a feature request for more Text manipulation functions was logged. But this and more complex calculations is possible using a 'Data Label' control and an 'Expression' to inject custom Javascript/JQuery code. These scripts will execute during run time. Perhaps the K2 community site (http://community.k2.com/t5/Forum/ct-p/K2-forum) or K2 Remote Services team can provide you with additional guidance.
 

 

Resolution

As a workaround for the time-being, Javascript injection was used to accomplished this:

 

 

 

1. Firstly, the Out-of-the-box 'Left' function is called on this Data Label to get up to 255 characters.

 

 

 

2. Then the Javascript 'lastIndexOf()' function is injected within a Data Label andgt Expression to find the index the last occurring semi-colon (or comma in your case) to get the index where the last email starts http://www.velocity-it.com/how-to-call-jquery-or-javascript-code-in-a-k2-smartform/ http://www.w3schools.com/jsref/jsref_lastindexof.asp

 

 

 

3. Lastly, the Out-of-the-box 'Left' function is used against the 255 character string (from 1) to get the sub-string up to this index (from 2) effectively returning all valid email address before hitting the 255 characters limit

 

 



 
Be the first to reply!

Reply