A permanent workflow is a workflow that, based on business needs or requirements, needs to run constantly or run automatically on a consistent schedule. For example, you may wish to create a workflow that runs once a day and sends an e-mail alert to a manager if any of their direct reports had not logged into the system in a certain number of days. In EmpowerID, a permanent workflow can only be run on one EmpowerID server and only one instance of the permanent workflow can run at a time.
Workflow Studio provides a permanent workflow template that makes it easy to create a custom permanent workflow. Once the permanent workflow is published to the EmpowerID server, configuring the job and schedule for the permanent workflow can be achieved with just a few steps in the EmpowerID Web interface. You can set the amount of idle time needed between runs and allow the permanent workflow to loop as needed for your business environment.
This topic demonstrates how to create a permanent workflow by creating one that runs once a day, disabling any user accounts for which the password has not changed in the past 90 days.
To create the permanent workflow
From the Workflow Studio, right-click on the Package node in which you want to create the workflow and select Add New Item > Workflow Application > Permanent Workflow Template from the context menu.
In theSave Workflowdialog that appears, specify aNameandDescriptionfor the permanent workflow.
Set the Life Expectancy to 3 Days and click OK.
Double-click the DoWork activity.
This opens the ExecuteCode event so that code can be added for the permanent workflow.
In the DoWork_ExecuteCode event, you can either call a SQL stored procedure you created (which is more efficient) or you can write the code to do the work you need done in the permanent workflow.
In this example, we add code to disable an account if the account password has not been changed in 90 days or more.
// create a variable for the total number of Accounts
int totalCount;
E.TList<Account> accounts = Account.GetAll(0, int.MaxValue, out totalCount);
// check each account
foreach (Account ac in accounts)
{
if (ac.Deleted && (ac.PasswordLastChanged == null || ac.PasswordLastChanged.Value.AddDays(90) < DateTime.UtcNow))
{
ac.Disable();
}
}
Save the workflow and then publish it by following the below steps.
To publish the permanent workflow
With thePermanent Workflowopen in the Workflow Studio Designer, click theCompile and Publishbutton located on the toolbar just above the Document Space.
In thePublish Workflowwizard that appears, click theNextbutton.
Select the server to which you want to publish the workflow and clickNext.
Wait for the wizard to compile the workflow and generate the Workflow activity assembly.
In theRequest Workflowdialog that appears, clickYesto create a new request workflow.
In theAdd Request Workflowdialog, make sure theNameandFriendly Namefor the Request Workflow are accurate, add aDescription as needed, and then clickOKto continue.
When prompted to restart one or more services, clickNo.
Next, configure the permanent workflow by following the below steps.
To configure the permanent workflow
From the Navigation Sidebar of the EmpowerID Web interface, expand Resources and click Workflows.
On the Workflows page, search for the request workflow you just published and then click the Display Name link for it.
On the Workflow Details page that appears, click the Edit link in the Search Tags pane.
Enter PermanentWorkflow in the Search Tags field, press ENTER and then click Save.
To allow the request workflow to be bound to a Permanent Workflow the workflow must be tagged with the PermanentWorkflow tag. The drop-down that allows you to select a request workflow for a permanent workflow lists only those request workflows with this tag.
From the Navigation Sidebar, expand Admin > EmpowerID Servers and Settings and click Permanent Workflows.
On the Permanent Workflows page, click the Add New button.
Enter a name and display name in the Name and Display Name fields, respectively.
Check Enabled to enable the workflow.
SetMax Items To Process In Loopto specify the number of items to retrieve with each loop. If the code for your workflows retrieves all records in one loop, this particular setting will be ignored.
SetMinutes To Pause Between Completed Runsto the appropriate number as necessary. This is the amount of idle time needed between each run of the permanent workflow. To run the workflow once per day, set this value to 1440.
In theRequest Workflowdrop-down, select your the request workflow you created in Workflow Studio. If you do not see the workflow in the drop-down, make sure it is tagged with the PermanentWorkflow tag.
The Permanent Workflow Details screen should look similar to the below image.