dynamics crm 2016 - Handling Action errors/output inside out-of-the-box Workflows -
i working on designing lengthy approval system in crm using combination of oob workflows (designed using crm ui workflow designer) , custom actions (actions written using .net code). idea keep entire branching/simpler logic in oob workflow , call custom actions wherever necessary. have few questions approach:
how can handle run-time errors generated in action code? example, 1 of actions contain code push data external system via web service. in case web service call fails, need perform steps in parent workflow.
how can handle 'if conditions' can't handled 'check condition' step? example, suppose before performing workflow step need check data can't queried within crm. can create action return true/false based on custom logic can checked in parent workflow.
an alternate approach use plugins inclined towards using oob functionalities as possible. inputs helpful.
first of let's clear semantics, because i'm not sure if understand talking - there actions (you can refer them custom actions, should refer every workflow create custom , figured out of post describing them oob, semantically wrong - every workflow create custom workflow, maybe it's using oob steps, that's different story) , custom workflow activities. i'm assuming want use custom workflow activities, because more suited trying achieve here. tagged question crm 2011 , crm 2013 - not sure meant, because actions not available crm 2011.
so custom workflow activities can have input , output parameters. output parameters answer both questions, because can use them error message after custom processing or use in conditional statements later in workflow. output parameters can defined that:
[output("error message")] public outargument<string> errormessage { get; set; }
you can find more examples here: https://technet.microsoft.com/en-us/library/gg327842.aspx
you can of course set properties calling
errormessage.set(executioncontext, messagetext)
so when define workflow, wherever need not configurable in oob blocks, can put custom block, after it's done check it's output error (this example, can pimp adding additional output parameters, make more generic), if it's empty something, if not else example send email error message. depends on trying achieve.
actions serving different purposes, useful create logic can called through plugin or javascript (webapi) , allows put plugin on alongside doing within 1 transaction. maybe useful somewhere in workflow, far remember in crm 2013 actions not called workflow...
update: ok if dealing crm 2016, can call action workflow. best in situation depends on scenario , trying achieve, make easier decide let me highlight main differences:
1) activities blocks of code can put inside workflow. actions themself not code, custom messages can call. of course can register plugin on custom message , there custom logic want, step take
2) actions can run in transaction, activities not (but can run activities inside actions, in case can run in transaction)
3) actions can called directly javascript, plugins , workflows. it's great thing, if make let's 10 custom actions using inside 1 workflow, visible when registering plugins (and js developer able call them js)
so actions big, fat feature can serve many purposes (including running activities on own!), activities simpler in case job. should ask questions:
do need logic run inside transaction?
and
do need call logic somewhere else workflow?
if have "yes" go actions, of no, go activities, because overcomplicating things without reason.
Comments
Post a Comment