Custom Workflow on Dynamic Content Items

Posted by Community Admin on 04-Aug-2018 15:23

Custom Workflow on Dynamic Content Items

All Replies

Posted by Community Admin on 04-Mar-2014 00:00

I have 13 dynamic Modules in which I am attempting to set up workflows for.  I am having an issue getting data from the workflow item.  One example of my Dynamic Module is "LandingPageTabs".  I have the following code:

var dataContext = context.DataContext;
var item = dataContext.GetProperties()["workflowItem"];
var module = item.GetValue(dataContext) as AnyDraftFacade;

The item is getting returned as null and I am uncertain as to why.  When I debug the item, I can see all the properties, but they are ALL listed as null  I have created workflows for Pages and get data (ID, Title, AvailableCultures, etc.) from the workflow item.  What am I doing incorrectly to not get any data?

 I have also done the following (found from other blog posts) and get everything to be null:

 var masterFluent = dataContext.GetProperties()["masterFluent"].GetValue(dataContext) as AnyDraftFacade;
var fluent = dataContext.GetProperties()["fluent"].GetValue(dataContext) as IAnyDraftFacade;

I have been using the following blog posts as reference:

www.sitefinity.com/.../custom-workflow

www.sitefinity.com/.../how_to_customize_sitefinity_workflow_notifications

www.sitefinity.com/.../workflow---feedaback-while-approving-the-content

 

The site I am working on is multilingual with 13 different languages.  What I am in need of is when the English version is "approved", the workflow will send an email to all the editors in the other language.  Then, when all items are "Awaiting Publishing", the users in Publisher Role get an email to publish all items.  I do have this working for Pages, but the logic does not appear to be the same for Content Items.   Any help on what I possibly could be doing wrong would be greatly appreciated.

Posted by Community Admin on 20-Mar-2014 00:00

Hello,

The item that is passing trough workflow is retreived with  the property masterFluent from the workflow context.

var dataContext = context.DataContext;
  
var masterFluent = dataContext.GetProperties()["masterFluent"].GetValue(dataContext) as MasterFacade;

The item is retrieved in the Execute method of the activity as the execute method caries the context data from the workflow execution. I recommend creating a class for the activity that inherits ExecuteCodeActivity (this is Sitefinity activity) and perform the operations over the module in this activity.

The item can be retrieved from the workflow by the id of the item tough all modules created with the module builder are using this workflow so check the type of module which is passing trough workflow and if the module is the correct type get the item ID to work with the item:

var dataContext = context.DataContext;
  
          var masterFluent = dataContext.GetProperties()["masterFluent"].GetValue(dataContext) as MasterFacade;
           
          //check the type of the module
          var moduletype = masterFluent.Get().GetType().FullName;
          if (moduletype == "Telerik.Sitefinity.DynamicTypes.Model.Schools.School")
          
              //get the id of the item passing trough workflow
              var itemId = masterFluent.Get().Id;
               
          
          if (moduletype == "Telerik.Sitefinity.DynamicTypes.Model.Schools.Teacher")
          
  
              //another logic
          

Once the item for specific module is retrieved use the API for each dynamic module (API reference for dynamic modules is available in Administration->Module builder, select a module and view "Code Reference"). Then you could implement your logic for sending emails to users.

Regards,
Stefani Tacheva
Telerik
 
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
 

This thread is closed