Programmatic use of workflow with notification

Posted by Community Admin on 04-Aug-2018 21:50

Programmatic use of workflow with notification

All Replies

Posted by Community Admin on 29-Aug-2014 00:00

I am working on a project with many data types created with the Module Builder.

I have a workflow enabled which generates emails when using the Sitefinity backend.

Now I am trying to use the workflow and notifications from buttons on the frontend.

I've been using IApprovalWorkflow.SetWorkflowStatus to change to "AwaitingApproval" etc. and then dynamicModuleBuilder.SaveChanges(). That was fine, but I also need to generate emails for Submit, Approve and Reject.

I found this:

and tried to add the "Send Item for Approval" to my code, but an email is not generated and there are no exceptions.

Does anyone have a sample of doing this with Module Builder data?

thanks in advance, 


Posted by Community Admin on 03-Sep-2014 00:00
Hello Scott,

I believe this could easiest achieved using custom workflow and there is a sample to what I believe you are trying to achieve here: Implement custom workflow activity

Hope this helps.

Vassil Vassilev
Do you want to have your say in the Sitefinity development roadmap? Do you want to know when a feature you requested is added or when a bug fixed? Explore the Telerik Sitefinity CMS Ideas&Feedback Portal and vote to affect the priority of the items
Posted by Community Admin on 03-Sep-2014 00:00

Thank you, Vassil. I have seen the information you posted, however I have two needs.

1) I cannot get the default workflow to run from my code.

2) I will also want to modify the content of the email, so that the notes about the state change are in the email.

Please see the code I am using for the custom submit button. Notes are normally saved for Rejected items only, but I am saving a note for Awaiting Approval, Rejected and Published. My "UnitEditable" field is controlling the ability to modify drafts on many other content types which act as multiple children to the one for which I am trying to create notifications.

The lines which are commented were not working for module builder data.

 Thank you, Scott

public string SubmitBudget(DynamicContent currentBudgetItem, string notes)
                if (currentBudgetItem.ApprovalWorkflowState != "AwaitingApproval")
                    var master = dynamicModuleManager.Lifecycle.GetMaster(currentBudgetItem) as DynamicContent;
                    var checkOutBudgetItem = dynamicModuleManager.Lifecycle.CheckOut(master) as DynamicContent;
                    checkOutBudgetItem.SetValue("UnitEditable", false);
                    ILifecycleDataItem checkInCourseItem = dynamicModuleManager.Lifecycle.CheckIn(checkOutBudgetItem);
                        dynamicModuleManager.Provider.ApplicationName, "AwaitingApproval", null,
                    //send item for approval
                    //var holder = new Dictionary<string, string>();
                    //holder.Add("ContentType", budgetType.FullName);
                    //WorkflowManager.MessageWorkflow(master.Id, budgetType, dynamicModuleManager.Provider.ToString(), "SendForApproval", false, holder);
                    return apmAlerts.Success("The current budget has been submitted for approval.");
                    return apmAlerts.Warning("The current budget was already awaiting approval.");
            catch (Exception e)
                return apmAlerts.Error("There was a problem submitting this budget for approval.<br />" + e.ToString());

This thread is closed