Skip to main content

I would like to modify a workflow so that based on say an environment variable (e.g. SendEmails = "true") notification emails get sent to the destination users only in the production environment. In the dev/test environments (e.g. SendEmails = "false") I want to send the emails to the process originator instead.

 

What I'm trying to avoid is having to modify the workflow each time when deploying to dev/test vs production environments.

 

Currently my task notification emails are being sent using a seperate email event just prior to the client event, rather than by using the "Notify participants when they receive a work item" option on the client event.

 

Has anyone come up with an elegant solution for this? I suppose I could use an expression on the To: field for the email event, but that would be a bit complicated I think.

Hi,

 

          You can send email notification  to different type of users “destination users” and ”process originator”  by drawing  to different activities with Email  notification event in parallel.

 

For Example:

  • Let suppose there are two activities  “Email to destination users” and ”Email to process originator” to send email .   
  • From parent activity draw parallel lines to connect these activities and  put line rule for each connecting line.
  • Line which is drawn towards “Email to destination users”  activity add  line rule SendEmails = "true".
  • Line which is drawn towards  ”Email to process originator”  activity  add  line rule SendEmails = "false".

 

In case if you are sending email for more events please create email process (i.e. IPC  email workflow)  and configured Child processes to complete in asynchronously fashion.

  


I have found  simple way I would reccomend you use eevn if you do not have two environments.

 

Store the users in an external list. Either a databse or SharePoint List. We have a workflow roles list with two collumns

1) Rolename (use this so you can use it for any workflow)

2) Role Member(s) (store their AD account name domainuser and semi colon delimit mutiple users.) If you use a delimited list in a task assignment be sure and use the split function.

 

Assuming that you have different database servers andor sharepoint servers you would have one copy with test users for Dev and one copy for prod users. If you only have one DB or SharePoint server you would have to use a variable to know which table for prod and which table for Dev or use one table and add a collumn for environment as set the environment variable from a system variable.

 

Another solution is to use K2 roles which can have different users in both environment or just use environment variables.

 

Rule number one for me is never put something in a workflow that could change later. I externalize: users, roles, and email sbjects and email bodies and even blocks of text on forms. Externalizing emails allows us to Put ***Test***Test*** in red on all emails from test system.

 

I hope this helps


Thanks for the suggestions. I should have clarified that the indvidual destination users are dynamic based upon who the originator selects when the process is initially created. So roles and groups do not help in this case.

 

Currently I'm trying expressions to generate the email addresses. The expressions are pretty complicated as they have several levels of nesting, and several smartobject calls, but I think its going to work. I'm using the URM smart objects to get the email addresses of the users from their user ids which I already have stored in the process.


I dont see an option to not email in the development environment unless you remove the email server.

 

2 other options

1) Maybe the option of just putting ***TEST*** at the top of emails in the test environment would be a solution

2) Have them select only test users on the form might be another option.

 

We never wanted to stop the emails because we wanted people to see them during test.

 

I hope this helps.

 

 

 


Hi oremac,

 

         From your requirements what i assumed is, based on different environment you want to send emails to two different type of users. In production for "destination users" and in Dev/Test for "process originator".

 

I would like to modify a workflow so that based on say an environment variable (e.g. SendEmails = "true") notification emails get sent to the destination users only in the production environment. In the dev/test environments (e.g. SendEmails = "false") I want to send the emails to the process originator instead.

 

If my assumption is wrong and you want to send email only in production and not in Dev/Test then I am agreed with Mickic point to append “Test Email” text in subject for “Dev/Test” environment.

 

 And 2nd option could be more helpful then multilevel nesting for you is put simple line rule to check environment type value to send emails. As several nesting of Inline Functions can affect server performance. “Inline Functions run in the context of the K2 Workflow Server, so they have the potential to affect server performance”.

 

 


Reply