Skip to main content

Hello Community,

 

I have a problem with a E-Mail event and the following error message

"The specified string is not in the form required for a subject".

 

The error occures when the users use a line break in the textfield for the Subject of the E-Mail.

 

Is there a way to delete those line breaks for the E-Mail subject?

In the form the line breaks are okay but for the E-Mail Subject it's bad.

 

I know there are a couple of solutions in the forum but those doesn't solved my problem.

 

Thank you for your help in advanced.

 

Kind regards

Alexander

 

Hi,

 

Please check below link.

Try Using Inline Function, This works for me.

 

http://community.k2.com/t5/tkb/articleprintpage/tkb-id/TKB_blackpearl/article-id/3106

 

Thanks,

Vijay.


Hi A_Christ,

Was the suggestion Vijay made useful, did it resolve your error?

Kind Regards,

Nicolaas Swart

Hello,

 

sorry for the late response.

Unfortunately does this solution doesn't fix my problem. I get the same error message as before.

 

Is this maybe a problem of the 4.7 Version?

Which character do you use for the replace function in the search section? Just a blank?

 

Thank you for your help.

 

Kind Regards

Alexander

 

 


Hi Alexander,

 

As you said, Looks like the inline function is not working in 4.7, which i have verified in my environment today.

 

So now to achieve this we have a work around which you can try following below steps.

 

Step 1: In E-Mail Activity, drag and drop a  Default Server Code Event and place it above the E-Mail Event so that Code event executes first and moves to email event.

Step 2: Right Click on Code Event -- Select View Code -- Select EventItem

Step 3: Now place below code inside Main method. Also Replace datafield name with the datadfield name of yours. mine here is "Subject"

 

string lineSeparator = ((char)0x2028).ToString();
string paragraphSeparator = ((char)0x2029).ToString();
K2.ProcessInstance.DataFieldsi"Subject"].Value = K2.ProcessInstance.DataFieldsi"Subject"].Value.ToString().Replace("
", string.Empty).Replace("
", string.Empty).Replace("
", string.Empty).Replace(lineSeparator, string.Empty).Replace(paragraphSeparator, string.Empty).Replace(Environment.NewLine, string.Empty);

 

Step 4: Save Close & Redeploy the Workflow. 

 

This should work for you!! Let me know once you try!!

 

 

Regards,

Vijay.


Hello Vijay,

 

I have just one little problem, I can't paste the code into my workflow.

When I use the right-click on this event (Default Server Event (Code)) there is no chance to paste any code.

 

Are there any requirements to use this event?

 

 

Kind Regards

Alexander


If this is K2 Studio, custom code cannot be added.  Perhaps you can pass this field to a data field and use purely inline functions to remove the line break:


 



 


Essentially:


 


- URL Encode to be able to target the line break '%0a'


- Replace it with a space or a character of your preference


- URL Decode it again


- Passed back into the same data label


- then use this data label in your email event


Hello Alexander,

 

For the solution that i have posted, you need to open the workflow in visual studio. If you don't have Visual Studio, then proceed with inline function suggested by Tin,

 

Take 2 Data Transfer Events before EMail Event

 

Data Transfer 1
Source : URL Decode(Replace(URL Encode(SubjectDataField),%0a, ))
Destination : SubjectDataField

 

Data Transfer 2
Source : URL Decode(Replace(URL Encode(SubjectDataField),%0d, ))
Destination : SubjectDataField

 

Now use SubjectDataField in Mail Event Subject.

 

Thanks,

Vijay.


Hello together,

 

the last post from Tin and Vijay has solved my problem.

 

Thank you all for your help.

 

Kind Regards

Alexander


Reply