Get Manager Type for Content
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.
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 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();
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.)
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);