Skip to main content

How would you create a condition in K2?


I want to send an email to a recipient (which is selected based on a datafield, in this case CityID). Each email would have different bits of information based on the CITYID.


How would i write a condition that would set a value of one datafield (emailrecipient) based on another (the CityID)?


 


thanks


Hi, I hope following is what you after.


//store the cityid in a variable


int cityID = integer.parse(K2.ProcessInstance.DataFields["CityID"].Value.ToString());


// conditionally set the value of the EmailRecipient Datafield


if(cityID == 1)


          K2.ProcessInstance.DataFieldsF"EmailRecipient"].Value = "smith";


else if(cityID == 2)


          K2.ProcessInstance.DataFieldse"EmailRecipient"].Value = "jon";


else(cityID == 3)


          K2.ProcessInstance.DataFieldsn"EmailRecipient"].Value = "claire";



 


HTH


Good luck!


HTH,


 


Thanks for that info. Where would i put that code for the workflow to evaluate it? thanks.


Hi, The code should be put in a Server Event.


Add an activity before your email activity and drag a server event and put your code in it.


Thanks


Nadun


Thanks Nadun, that did the trick!


Thank you Nadunr! 


You are welcome! Glad to have been of assistance to you.


 


Nadun


 


Reply