API
Version 7.x > API > Derive from Condition Workflow Action View modes: 
User avatar
Certified Developer v6
Certified Developer v6
Dave - 3/13/2013 2:06:41 PM
   
Derive from Condition Workflow Action
Hi,

I am using your Advanced Workflow feature, and would like to use your Condition Workflow Action, but would prefer not to use macros, and instead use straight c# code. I was hoping to inherit from a "ConditionWorkflowAction" class, but couldn't find one. How do you recommend best accomplishing this?

Thanks,
Dave

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 3/14/2013 8:58:01 AM
   
RE:Derive from Condition Workflow Action
Hi Dave,

You can do in the code-behind using our API (See Documentation section at the top on the Devnet) where you can use also the C# code instead of macros. Feel free to take inspiration from our API Examples (CMSSiteManager -> Support -> Api Examples).
Under Documents -> Workflow Basics as well as Advanced.

Best regards,
Martin Danko

User avatar
Certified Developer v6
Certified Developer v6
Dave - 3/14/2013 9:39:02 AM
   
RE:Derive from Condition Workflow Action
Thanks Martin,

Unfortunately I was not able to find what I was looking for in either the API documentation or the API Examples. Would you mind pointing me to the specific section or page?

Thanks,
Dave

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 3/19/2013 3:03:27 AM
   
RE:Derive from Condition Workflow Action
Hi Dave,

So I've discussed your issue with our development team and they confirmed that at the moment there is no exact functionality you are asking for. But could you please tell me what do you want to achieve and maybe we will find some workaround?

Best regards,
Martin Danko

User avatar
Certified Developer v6
Certified Developer v6
Dave - 3/21/2013 8:24:04 AM
   
RE:Derive from Condition Workflow Action
Hi Martin,

Basically I'm trying to create a custom Workflow step that I can use against a custom-coded check, and move the workflow into either a success or failure path (like the Conditional Workflow action).

The two ways to implement I can think of would be to completely custom code the workflow step, or possibly create a very customized macro to use in the Conditional Workflow action. What do your developers recommend? Also, would you be able to point me to the code of the Conditional Workflow action?

Thanks!
Dave

User avatar
Certified Developer v6
Certified Developer v6
Dave - 3/21/2013 9:22:28 AM
   
RE:Derive from Condition Workflow Action
Related to this, I'd also be interested in knowing how to programmatically trigger a particular path on a Multi-choice workflow step.

User avatar
Kentico Legend
Kentico Legend
Brenden Kehren - 3/21/2013 12:48:36 PM
   
RE:Derive from Condition Workflow Action
Dave wrote:
Related to this, I'd also be interested in knowing how to programmatically trigger a particular path on a Multi-choice workflow step.

I think this is what you're looking for. You could set the aliasPath parameter as an input parameter and based on what your previous code finds (success/failure) you can set the path as needed and move to a specific workflow step. This is an example out of the CMSAPIExamples
CMS.DocumentEngine.TreeProvider tree = new CMS.DocumentEngine.TreeProvider(CMSContext.CurrentUser);
// Prepare parameters
string sitename = CMSContext.CurrentSiteName;
string aliasPath = "/API-Example";
string culture = "en-us";
bool combineWithDefaultCulture = false;
string classNames = CMS.DocumentEngine.TreeProvider.ALL_CLASSNAMES;
string where = null;
string orderBy = null;
int maxRelativeLevel = -1;
bool selectOnlyPublished = false;
string columns = null;

// Get the document
CMS.DocumentEngine.TreeNode node = CMS.DocumentEngine.DocumentHelper.GetDocument(sitename, aliasPath, culture, combineWithDefaultCulture, classNames, where, orderBy, maxRelativeLevel, selectOnlyPublished, columns, tree);

if (node != null)
{
CMS.DocumentEngine.WorkflowManager workflowManager = CMS.DocumentEngine.WorkflowManager.GetInstance(tree);

CMS.WorkflowEngine.WorkflowInfo workflow = workflowManager.GetNodeWorkflow(node);

// Check if the document uses workflow
if (workflow != null)
{
CMS.WorkflowEngine.WorkflowStepInfo stepInfo = CMS.WorkflowEngine.WorkflowStepInfoProvider.GetWorkflowStepInfo("your step name", workflow.WorkflowID);
workflowManager.MoveToSpecificStep(node, stepInfo, "your comment");
}
}

User avatar
Kentico Customer Success
Kentico Customer Success
kentico_martind2 - 3/27/2013 9:23:51 AM
   
RE:Derive from Condition Workflow Action
Hi Dave,

I have consulted it with our developers and you're right... if you want to evaluate your custom code, a custom macro is the best and easiest way.

I don't know what exactly do you mean by the code of the conditional action. This behaviour is implemented in the logic of workflow engine - if it detects that it's a condition step, then the condition is evaluated and depending on the result of the condition it continues to one of the branches.

Best regards,
Martin Danko