Get Manager Type for Content

Posted by Community Admin on 04-Aug-2018 17:54

Get Manager Type for Content

All Replies

Posted by Community Admin on 28-Feb-2014 00:00

I am in the process of customizing the workflow for ALL content items.  I will be sending custom emails to the users in the different roles set up throughout the workflow.  That part of the workflow I have figured out.  What I cannot figure out is how do I get the appropriate "Content Manager" for the content item.  The content item could be a news item, blog item, image, document, content item, custom content, etc.  Each content has its own "Manager".  I have searched and found nothing yet that is helping me.

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

Hello Jared,

I suppose you have followed this blog post or at least your solution comes close to it. You need to get the current item that is being processed and check its type. Then depending on this type you can use a switch to instantiate the respective manager depending on the case. To get the currently processed item you can do the following:

protected override void Execute(CodeActivityContext context)
        
            var dataContext = context.DataContext;
            var masterFluent = dataContext.GetProperties()["masterFluent"].GetValue(dataContext) as AnyDraftFacade; 
   
            var currentlyProcessedItem = masterFluent.Get()
var type = currentlyProcessedItem.GetType().FullName
        
 
I hope this helps.

Regards,
Pavel Benov
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

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

I tried this and still having no luck.  The issue is around the following line of code:

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

The issue is that the above line returns "null".  Then on the following line of code below I get "Object Reference not set to instance of an object".  The code you provided declares masterFluent "as AnyDraftFacade".  Is that correct?  This is the issue I have been having for days now trying to figure this out.

var currentItem = masterFluent.Get();

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

I have the following code within y workflow:

var dataContext = context.DataContext;
var workflowDefinition = (WorkflowDefinition)dataContext.GetProperties()["workflowDefinition"].GetValue(dataContext);
 
var workflowItem = dataContext.GetProperties()["workflowItem"];
var fluentItem = dataContext.GetProperties()["fluent"];
var masterFluentItem = dataContext.GetProperties()["masterFluent"];
 
var module = workflowItem.GetValue(dataContext) as DynamicContent;
var module1 = workflowItem.GetValue(dataContext);
var module4 = fluentItem.GetValue(dataContext);
var module7 = masterFluentItem.GetValue(dataContext);

Below is the values I get for the "Type" of each item:

masterFluentItem.GetValue(dataContext)
Name = "MasterFacade" FullName = "Telerik.Sitefinity.Lifecycle.Fluent.MasterFacade"
 
fluentItem.GetValue(dataContext)   
Name = "TempFacade" FullName = "Telerik.Sitefinity.Lifecycle.Fluent.TempFacade"
 
workflowItem.GetValue(dataContext) 
Name = "LandingPageTab" FullName = "Telerik.Sitefinity.DynamicTypes.Model.LandingPageTabs.LandingPageTab"


I am having troubles getting the "currentItem" values (content, ID, AvailableCultures, etc.)






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

Below is what I have done to get the information that I need.  All the data I need exist in either "item" or "data"

var dataContext = context.DataContext;
var workflowDefinition = (WorkflowDefinition)dataContext.GetProperties()["workflowDefinition"].GetValue(dataContext);
var manager = DynamicModuleManager.GetManager();
 
//Get Item Obect
var workflowItem = dataContext.GetProperties()["workflowItem"];
var masterFluent = (MasterFacade)dataContext.GetProperties()["masterFluent"].GetValue(dataContext);
 
//Get Module
var module = masterFluent.Get();
//Get Module Type
Type type = module.GetType();
//Get Data Item
var item = manager.GetDataItem(type, module.Id);
//Get Data Object
var data = manager.GetItem(type, module.Id);

This thread is closed