Produced by Araxis Merge on 2/1/2017 2:56:54 PM Eastern Standard Time. See www.araxis.com for information about Merge. This report uses XHTML and CSS2, and is best viewed with a modern standards-compliant browser. For optimum results when printing this report, use landscape orientation and enable printing of background images and colours in your browser.
| # | Location | File | Last Modified |
|---|---|---|---|
| 1 | C:\Araxis_Merge_Comprasion\Pub_un\BTSSS_CIF_122016.zip\BTSSS_CIF_12_20_16\clean\CRM\trunk\SDK\SampleCode\CS\Process\Workflows | ExecuteWorkflow.cs | Tue Dec 20 19:51:45 2016 UTC |
| 2 | Wed Feb 1 19:56:54 2017 UTC |
| Description | Between Files 1 and 2 |
|
|---|---|---|
| Text Blocks | Lines | |
| Unchanged | 0 | 0 |
| Changed | 0 | 0 |
| Inserted | 0 | 0 |
| Removed | 1 | 464 |
| Whitespace | |
|---|---|
| Character case | Differences in character case are significant |
| Line endings | Differences in line endings (CR and LF characters) are ignored |
| CR/LF characters | Not shown in the comparison detail |
No regular expressions were active.
| 1 | // ======= ========== ========== ========== ========== ========== ========== ========== = | |||||
| 2 | // This f ile is par t of the M icrosoft D ynamics CR M SDK Code Samples. | |||||
| 3 | // | |||||
| 4 | // Copyri ght (C) Mi crosoft Co rporation. All righ ts reserve d. | |||||
| 5 | // | |||||
| 6 | // This s ource code is intend ed only as a supplem ent to Mic rosoft | |||||
| 7 | // Develo pment Tool s and/or o n-line doc umentation . See the se other | |||||
| 8 | // materi als for de tailed inf ormation r egarding M icrosoft c ode sample s. | |||||
| 9 | // | |||||
| 10 | // THIS C ODE AND IN FORMATION ARE PROVID ED "AS IS" WITHOUT W ARRANTY OF ANY | |||||
| 11 | // KIND, EITHER EXP RESSED OR IMPLIED, I NCLUDING B UT NOT LIM ITED TO TH E | |||||
| 12 | // IMPLIE D WARRANTI ES OF MERC HANTABILIT Y AND/OR F ITNESS FOR A | |||||
| 13 | // PARTIC ULAR PURPO SE. | |||||
| 14 | // ======= ========== ========== ========== ========== ========== ========== ========== = | |||||
| 15 | ||||||
| 16 | //<snippet ExecuteWor kflow> | |||||
| 17 | using Syst em; | |||||
| 18 | using Syst em.Linq; | |||||
| 19 | using Syst em.Service Model; | |||||
| 20 | ||||||
| 21 | // These n amespaces are found in the Mic rosoft.Xrm .Sdk.dll a ssembly | |||||
| 22 | // found i n the SDK\ bin folder . | |||||
| 23 | using Micr osoft.Xrm. Sdk; | |||||
| 24 | using Micr osoft.Xrm. Sdk.Client ; | |||||
| 25 | using Micr osoft.Xrm. Sdk.Query; | |||||
| 26 | ||||||
| 27 | // This na mespace is found in Microsoft. Crm.Sdk.Pr oxy.dll as sembly | |||||
| 28 | // found i n the SDK\ bin folder . | |||||
| 29 | using Micr osoft.Crm. Sdk.Messag es; | |||||
| 30 | ||||||
| 31 | namespace Microsoft. Crm.Sdk.Sa mples | |||||
| 32 | { | |||||
| 33 | /// <s ummary> | |||||
| 34 | /// Ex ecute a wo rkflow pro grammatica lly. | |||||
| 35 | /// </ summary> | |||||
| 36 | public class Exe cuteWorkfl ow | |||||
| 37 | { | |||||
| 38 | ||||||
| 39 | #r egion Clas s Level Me mbers | |||||
| 40 | ||||||
| 41 | pr ivate Guid _workflow Id; | |||||
| 42 | pr ivate Guid _leadId; | |||||
| 43 | pr ivate Guid _asyncOpe rationId; | |||||
| 44 | pr ivate Orga nizationSe rviceProxy _serviceP roxy; | |||||
| 45 | ||||||
| 46 | #e ndregion C lass Level Members | |||||
| 47 | ||||||
| 48 | #r egion How- To Sample Code | |||||
| 49 | // / <summary > | |||||
| 50 | // / Demonstr ates how t o programm atically e xecute a w orkflow. | |||||
| 51 | // / </summar y> | |||||
| 52 | // / <param n ame="serve rConfig">C ontains se rver conne ction info rmation.</ param> | |||||
| 53 | // / <param n ame="promp tforDelete ">When Tru e, the use r will be prompted t o delete a ll | |||||
| 54 | // / created entities.< /param> | |||||
| 55 | pu blic void Run(Server Connection .Configura tion serve rConfig, b ool prompt forDelete) | |||||
| 56 | { | |||||
| 57 | try | |||||
| 58 | { | |||||
| 59 | ||||||
| 60 | // C onnect to the Organi zation ser vice. | |||||
| 61 | // T he using s tatement a ssures tha t the serv ice proxy will be pr operly dis posed. | |||||
| 62 | usin g (_servic eProxy = n ew Organiz ationServi ceProxy(se rverConfig .Organizat ionUri, se rverConfig .HomeRealm Uri,server Config.Cre dentials, serverConf ig.DeviceC redentials )) | |||||
| 63 | { | |||||
| 64 | // This st atement is required to enable early-boun d type sup port. | |||||
| 65 | _servicePr oxy.Enable ProxyTypes (); | |||||
| 66 | ||||||
| 67 | Organizati onServiceC ontext _or gContext = new Organ izationSer viceContex t(_service Proxy); | |||||
| 68 | ||||||
| 69 | CreateRequ iredRecord s(); | |||||
| 70 | ||||||
| 71 | //<snippet ExecuteWor kflow1> | |||||
| 72 | // Create an Execute Workflow r equest. | |||||
| 73 | ExecuteWor kflowReque st request = new Exe cuteWorkfl owRequest( ) | |||||
| 74 | { | |||||
| 75 | Workfl owId = _wo rkflowId, | |||||
| 76 | Entity Id = _lead Id | |||||
| 77 | }; | |||||
| 78 | Console.Wr ite("Creat ed Execute Workflow r equest, ") ; | |||||
| 79 | ||||||
| 80 | // Execute the workf low. | |||||
| 81 | ExecuteWor kflowRespo nse respon se = | |||||
| 82 | (Execu teWorkflow Response)_ servicePro xy.Execute (request); | |||||
| 83 | Console.Wr iteLine("a nd sent re quest to s ervice."); | |||||
| 84 | ||||||
| 85 | //</snippe tExecuteWo rkflow1> | |||||
| 86 | ||||||
| 87 | #region Ch eck succes s | |||||
| 88 | ||||||
| 89 | ColumnSet cols = new ColumnSet ("statecod e"); | |||||
| 90 | QueryByAtt ribute ret rieveOpQue ry = new Q ueryByAttr ibute(); | |||||
| 91 | retrieveOp Query.Enti tyName = A syncOperat ion.Entity LogicalNam e; | |||||
| 92 | retrieveOp Query.Colu mnSet = co ls; | |||||
| 93 | retrieveOp Query.AddA ttributeVa lue("async operationi d", respon se.Id); | |||||
| 94 | ||||||
| 95 | // Wait fo r the asyn coperation to comple te. | |||||
| 96 | // (wait n o longer t han 1 minu te) | |||||
| 97 | for (int i = 0; i < 60; i++) | |||||
| 98 | { | |||||
| 99 | System .Threading .Thread.Sl eep(1000); | |||||
| 100 | ||||||
| 101 | Entity Collection retrieveO pResults = | |||||
| 102 | _s erviceProx y.Retrieve Multiple(r etrieveOpQ uery); | |||||
| 103 | ||||||
| 104 | if (re trieveOpRe sults.Enti ties.Count () > 0) | |||||
| 105 | { | |||||
| 106 | As yncOperati on op = | |||||
| 107 | (AsyncOp eration)re trieveOpRe sults.Enti ties[0]; | |||||
| 108 | if (op.State Code == As yncOperati onState.Co mpleted) | |||||
| 109 | { | |||||
| 110 | _asyncOp erationId = op.Async OperationI d.Value; | |||||
| 111 | Console. WriteLine( "AsyncOper ation comp leted succ essfully." ); | |||||
| 112 | break; | |||||
| 113 | } | |||||
| 114 | } | |||||
| 115 | ||||||
| 116 | if (i == 59) | |||||
| 117 | { | |||||
| 118 | th row new Ti meoutExcep tion("Asyn cOperation failed to complete in under o ne minute. "); | |||||
| 119 | } | |||||
| 120 | } | |||||
| 121 | ||||||
| 122 | // Retriev e the task that was created by the workf low. | |||||
| 123 | cols = new ColumnSet ("activity id"); | |||||
| 124 | QueryByAtt ribute ret rieveActiv ityQuery = new Query ByAttribut e(); | |||||
| 125 | retrieveAc tivityQuer y.EntityNa me = Phone Call.Entit yLogicalNa me; | |||||
| 126 | retrieveAc tivityQuer y.ColumnSe t = cols; | |||||
| 127 | retrieveAc tivityQuer y.AddAttri buteValue( "subject", "First ca ll to Diog o Andrade" ); | |||||
| 128 | ||||||
| 129 | EntityColl ection res ults = | |||||
| 130 | _servi ceProxy.Re trieveMult iple(retri eveActivit yQuery); | |||||
| 131 | ||||||
| 132 | if (result s.Entities .Count() = = 0) | |||||
| 133 | { | |||||
| 134 | throw new Invali dOperation Exception( "Phone cal l activity was not s uccessfull y created" ); | |||||
| 135 | } | |||||
| 136 | else | |||||
| 137 | { | |||||
| 138 | Consol e.WriteLin e("Phone c all activi ty success fully crea ted from w orkflow.") ; | |||||
| 139 | } | |||||
| 140 | ||||||
| 141 | #endregion Check suc cess | |||||
| 142 | ||||||
| 143 | DeleteRequ iredRecord s(promptfo rDelete); | |||||
| 144 | } | |||||
| 145 | ||||||
| 146 | } | |||||
| 147 | ||||||
| 148 | // Catch any servi ce fault e xceptions that Micro soft Dynam ics CRM th rows. | |||||
| 149 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault>) | |||||
| 150 | { | |||||
| 151 | // Y ou can han dle an exc eption her e or pass it back to the calli ng method. | |||||
| 152 | thro w; | |||||
| 153 | } | |||||
| 154 | } | |||||
| 155 | ||||||
| 156 | // / <summary > | |||||
| 157 | // / Creates any entity records t hat this s ample requ ires. | |||||
| 158 | // / </summar y> | |||||
| 159 | pu blic void CreateRequ iredRecord s() | |||||
| 160 | { | |||||
| 161 | // Creat e a Lead r ecord on w hich we wi ll execute the Workf low. | |||||
| 162 | Lead lea d = new Le ad() | |||||
| 163 | { | |||||
| 164 | Firs tName = "D iogo", | |||||
| 165 | Last Name = "An drade" | |||||
| 166 | }; | |||||
| 167 | _leadId = _service Proxy.Crea te(lead); | |||||
| 168 | Console. WriteLine( "Created L ead for wo rkflow req uest."); | |||||
| 169 | ||||||
| 170 | // Defin e an anony mous type to define the possib le values for | |||||
| 171 | // proce ss type | |||||
| 172 | var Proc essType = new | |||||
| 173 | { | |||||
| 174 | Defi nition = 1 , | |||||
| 175 | Acti vation = 2 , | |||||
| 176 | Temp late = 3 | |||||
| 177 | }; | |||||
| 178 | ||||||
| 179 | // Defin e an anony mous type to define the possib le values for | |||||
| 180 | // proce ss categor y | |||||
| 181 | var Proc essCategor y = new | |||||
| 182 | { | |||||
| 183 | Work flow = 0, | |||||
| 184 | Dial og = 1, | |||||
| 185 | }; | |||||
| 186 | ||||||
| 187 | // Defin e an anony mous type to define the possib le values for | |||||
| 188 | // proce ss scope | |||||
| 189 | var Proc essScope = new | |||||
| 190 | { | |||||
| 191 | User = 1, | |||||
| 192 | Busi nessUnit = 2, | |||||
| 193 | Deep = 3, | |||||
| 194 | Glob al = 4 | |||||
| 195 | }; | |||||
| 196 | ||||||
| 197 | // Creat e the Work flow that we will ex ecute. | |||||
| 198 | Workflow workflow = new Work flow() | |||||
| 199 | { | |||||
| 200 | Name = "Sample Workflow" , // frien dly name o f the reco rd | |||||
| 201 | Type = new Opt ionSetValu e(ProcessT ype.Defini tion), | |||||
| 202 | Cate gory = new OptionSet Value(Proc essCategor y.Workflow ), | |||||
| 203 | Scop e = new Op tionSetVal ue(Process Scope.User ), | |||||
| 204 | OnDe mand = tru e, | |||||
| 205 | Prim aryEntity = Lead.Ent ityLogical Name, | |||||
| 206 | Xaml = | |||||
| 207 | @"<?xml ve rsion=""1. 0"" encodi ng=""utf-1 6""?> | |||||
| 208 | <Activity x:Class="" ExecuteWor kflowSampl e"" xmlns= ""http://s chemas.mic rosoft.com /netfx/200 9/xaml/act ivities"" xmlns:mva= ""clr-name space:Micr osoft.Visu alBasic.Ac tivities;a ssembly=Sy stem.Activ ities, Ver sion=4.0.0 .0, Cultur e=neutral, PublicKey Token=31bf 3856ad364e 35"" xmlns :mxs=""clr -namespace :Microsoft .Xrm.Sdk;a ssembly=Mi crosoft.Xr m.Sdk, Ver sion=5.0.0 .0, Cultur e=neutral, PublicKey Token=31bf 3856ad364e 35"" xmlns :mxswa=""c lr-namespa ce:Microso ft.Xrm.Sdk .Workflow. Activities ;assembly= Microsoft. Xrm.Sdk.Wo rkflow, Ve rsion=5.0. 0.0, Cultu re=neutral , PublicKe yToken=31b f3856ad364 e35"" xmln s:s=""clr- namespace: System;ass embly=msco rlib, Vers ion=4.0.0. 0, Culture =neutral, PublicKeyT oken=b77a5 c561934e08 9"" xmlns: scg=""clr- namespace: System.Col lections.G eneric;ass embly=msco rlib, Vers ion=4.0.0. 0, Culture =neutral, PublicKeyT oken=b77a5 c561934e08 9"" xmlns: srs=""clr- namespace: System.Run time.Seria lization;a ssembly=Sy stem.Runti me.Seriali zation, Ve rsion=4.0. 0.0, Cultu re=neutral , PublicKe yToken=b77 a5c561934e 089"" xmln s:this=""c lr-namespa ce:"" xmln s:x=""http ://schemas .microsoft .com/winfx /2006/xaml ""> | |||||
| 209 | <x:Membe rs> | |||||
| 210 | <x:Pro perty Name =""InputEn tities"" T ype=""InAr gument(scg :IDictiona ry(x:Strin g, mxs:Ent ity))"" /> | |||||
| 211 | <x:Pro perty Name =""Created Entities"" Type=""In Argument(s cg:IDictio nary(x:Str ing, mxs:E ntity))"" /> | |||||
| 212 | </x:Memb ers> | |||||
| 213 | <this:Ex ecuteWorkf lowSample. InputEntit ies> | |||||
| 214 | <InArg ument x:Ty peArgument s=""scg:ID ictionary( x:String, mxs:Entity )"" /> | |||||
| 215 | </this:E xecuteWork flowSample .InputEnti ties> | |||||
| 216 | <this:Ex ecuteWorkf lowSample. CreatedEnt ities> | |||||
| 217 | <InArg ument x:Ty peArgument s=""scg:ID ictionary( x:String, mxs:Entity )"" /> | |||||
| 218 | </this:E xecuteWork flowSample .CreatedEn tities> | |||||
| 219 | <mva:Vis ualBasic.S ettings>As sembly ref erences an d imported namespace s for inte rnal imple mentation< /mva:Visua lBasic.Set tings> | |||||
| 220 | <mxswa:W orkflow> | |||||
| 221 | <Assig n x:TypeAr guments="" mxs:Entity "" To=""[C reatedEnti ties(" ;CreateSte p1_localPa rameter#Te mp")] "" Value=" "[New Enti ty("p honecall&q uot;)]"" / > | |||||
| 222 | <Seque nce Displa yName=""Cr eateStep1: Set first activity for lead." "> | |||||
| 223 | <Seq uence.Vari ables> | |||||
| 224 | <V ariable x: TypeArgume nts=""x:Ob ject"" Nam e=""Create Step1_1"" /> | |||||
| 225 | <V ariable x: TypeArgume nts=""x:Ob ject"" Nam e=""Create Step1_2"" /> | |||||
| 226 | <V ariable x: TypeArgume nts=""x:Ob ject"" Nam e=""Create Step1_3"" /> | |||||
| 227 | <V ariable x: TypeArgume nts=""x:Ob ject"" Nam e=""Create Step1_4"" /> | |||||
| 228 | <V ariable x: TypeArgume nts=""x:Ob ject"" Nam e=""Create Step1_5"" /> | |||||
| 229 | <V ariable x: TypeArgume nts=""x:Ob ject"" Nam e=""Create Step1_6"" /> | |||||
| 230 | <V ariable x: TypeArgume nts=""x:Ob ject"" Nam e=""Create Step1_7"" /> | |||||
| 231 | <V ariable x: TypeArgume nts=""x:Ob ject"" Nam e=""Create Step1_8"" /> | |||||
| 232 | </Se quence.Var iables> | |||||
| 233 | <mxs wa:Activit yReference AssemblyQ ualifiedNa me=""Micro soft.Crm.W orkflow.Ac tivities.E valuateExp ression, M icrosoft.C rm.Workflo w, Version =5.0.0.0, Culture=ne utral, Pub licKeyToke n=31bf3856 ad364e35"" DisplayNa me=""Evalu ateExpress ion""> | |||||
| 234 | <m xswa:Activ ityReferen ce.Argumen ts> | |||||
| 235 | <InArgumen t x:TypeAr guments="" x:String"" x:Key=""E xpressionO perator""> CreateCrmT ype</InArg ument> | |||||
| 236 | <InArgumen t x:TypeAr guments="" s:Object[] "" x:Key=" "Parameter s"">[New O bject() { Microsoft. Xrm.Sdk.Wo rkflow.Wor kflowPrope rtyType.Bo olean, ""T rue"" }]</ InArgument > | |||||
| 237 | <InArgumen t x:TypeAr guments="" s:Type"" x :Key=""Tar getType""> | |||||
| 238 | <mxswa:R eferenceLi teral x:Ty peArgument s=""s:Type "" Value=" "x:Boolean "" /> | |||||
| 239 | </InArgume nt> | |||||
| 240 | <OutArgume nt x:TypeA rguments=" "x:Object" " x:Key="" Result"">[ CreateStep 1_1]</OutA rgument> | |||||
| 241 | </ mxswa:Acti vityRefere nce.Argume nts> | |||||
| 242 | </mx swa:Activi tyReferenc e> | |||||
| 243 | <mxs wa:SetEnti tyProperty Attribute =""directi oncode"" E ntity=""[C reatedEnti ties(" ;CreateSte p1_localPa rameter#Te mp")] "" EntityN ame=""phon ecall"" Va lue=""[Cre ateStep1_1 ]""> | |||||
| 244 | <m xswa:SetEn tityProper ty.TargetT ype> | |||||
| 245 | <InArgumen t x:TypeAr guments="" s:Type""> | |||||
| 246 | <mxswa:R eferenceLi teral x:Ty peArgument s=""s:Type "" Value=" "x:Boolean "" /> | |||||
| 247 | </InArgume nt> | |||||
| 248 | </ mxswa:SetE ntityPrope rty.Target Type> | |||||
| 249 | </mx swa:SetEnt ityPropert y> | |||||
| 250 | <mxs wa:Activit yReference AssemblyQ ualifiedNa me=""Micro soft.Crm.W orkflow.Ac tivities.E valuateExp ression, M icrosoft.C rm.Workflo w, Version =5.0.0.0, Culture=ne utral, Pub licKeyToke n=31bf3856 ad364e35"" DisplayNa me=""Evalu ateExpress ion""> | |||||
| 251 | <m xswa:Activ ityReferen ce.Argumen ts> | |||||
| 252 | <InArgumen t x:TypeAr guments="" x:String"" x:Key=""E xpressionO perator""> CreateCrmT ype</InArg ument> | |||||
| 253 | <InArgumen t x:TypeAr guments="" s:Object[] "" x:Key=" "Parameter s"">[New O bject() { Microsoft. Xrm.Sdk.Wo rkflow.Wor kflowPrope rtyType.St ring, ""Fi rst call t o "", ""St ring"" }]< /InArgumen t> | |||||
| 254 | <InArgumen t x:TypeAr guments="" s:Type"" x :Key=""Tar getType""> | |||||
| 255 | <mxswa:R eferenceLi teral x:Ty peArgument s=""s:Type "" Value=" "x:String" " /> | |||||
| 256 | </InArgume nt> | |||||
| 257 | <OutArgume nt x:TypeA rguments=" "x:Object" " x:Key="" Result"">[ CreateStep 1_3]</OutA rgument> | |||||
| 258 | </ mxswa:Acti vityRefere nce.Argume nts> | |||||
| 259 | </mx swa:Activi tyReferenc e> | |||||
| 260 | <mxs wa:GetEnti tyProperty Attribute =""fullnam e"" Entity =""[InputE ntities(&q uot;primar yEntity&qu ot;)]"" En tityName=" "lead"" Va lue=""[Cre ateStep1_5 ]""> | |||||
| 261 | <m xswa:GetEn tityProper ty.TargetT ype> | |||||
| 262 | <InArgumen t x:TypeAr guments="" s:Type""> | |||||
| 263 | <mxswa:R eferenceLi teral x:Ty peArgument s=""s:Type "" Value=" "x:String" " /> | |||||
| 264 | </InArgume nt> | |||||
| 265 | </ mxswa:GetE ntityPrope rty.Target Type> | |||||
| 266 | </mx swa:GetEnt ityPropert y> | |||||
| 267 | <mxs wa:Activit yReference AssemblyQ ualifiedNa me=""Micro soft.Crm.W orkflow.Ac tivities.E valuateExp ression, M icrosoft.C rm.Workflo w, Version =5.0.0.0, Culture=ne utral, Pub licKeyToke n=31bf3856 ad364e35"" DisplayNa me=""Evalu ateExpress ion""> | |||||
| 268 | <m xswa:Activ ityReferen ce.Argumen ts> | |||||
| 269 | <InArgumen t x:TypeAr guments="" x:String"" x:Key=""E xpressionO perator""> SelectFirs tNonNull</ InArgument > | |||||
| 270 | <InArgumen t x:TypeAr guments="" s:Object[] "" x:Key=" "Parameter s"">[New O bject() { CreateStep 1_5 }]</In Argument> | |||||
| 271 | <InArgumen t x:TypeAr guments="" s:Type"" x :Key=""Tar getType""> | |||||
| 272 | <mxswa:R eferenceLi teral x:Ty peArgument s=""s:Type "" Value=" "x:String" " /> | |||||
| 273 | </InArgume nt> | |||||
| 274 | <OutArgume nt x:TypeA rguments=" "x:Object" " x:Key="" Result"">[ CreateStep 1_4]</OutA rgument> | |||||
| 275 | </ mxswa:Acti vityRefere nce.Argume nts> | |||||
| 276 | </mx swa:Activi tyReferenc e> | |||||
| 277 | <mxs wa:Activit yReference AssemblyQ ualifiedNa me=""Micro soft.Crm.W orkflow.Ac tivities.E valuateExp ression, M icrosoft.C rm.Workflo w, Version =5.0.0.0, Culture=ne utral, Pub licKeyToke n=31bf3856 ad364e35"" DisplayNa me=""Evalu ateExpress ion""> | |||||
| 278 | <m xswa:Activ ityReferen ce.Argumen ts> | |||||
| 279 | <InArgumen t x:TypeAr guments="" x:String"" x:Key=""E xpressionO perator""> Add</InArg ument> | |||||
| 280 | <InArgumen t x:TypeAr guments="" s:Object[] "" x:Key=" "Parameter s"">[New O bject() { CreateStep 1_3, Creat eStep1_4 } ]</InArgum ent> | |||||
| 281 | <InArgumen t x:TypeAr guments="" s:Type"" x :Key=""Tar getType""> | |||||
| 282 | <mxswa:R eferenceLi teral x:Ty peArgument s=""s:Type "" Value=" "x:String" " /> | |||||
| 283 | </InArgume nt> | |||||
| 284 | <OutArgume nt x:TypeA rguments=" "x:Object" " x:Key="" Result"">[ CreateStep 1_2]</OutA rgument> | |||||
| 285 | </ mxswa:Acti vityRefere nce.Argume nts> | |||||
| 286 | </mx swa:Activi tyReferenc e> | |||||
| 287 | <mxs wa:SetEnti tyProperty Attribute =""subject "" Entity= ""[Created Entities(& quot;Creat eStep1_loc alParamete r#Temp&quo t;)]"" Ent ityName="" phonecall" " Value="" [CreateSte p1_2]""> | |||||
| 288 | <m xswa:SetEn tityProper ty.TargetT ype> | |||||
| 289 | <InArgumen t x:TypeAr guments="" s:Type""> | |||||
| 290 | <mxswa:R eferenceLi teral x:Ty peArgument s=""s:Type "" Value=" "x:String" " /> | |||||
| 291 | </InArgume nt> | |||||
| 292 | </ mxswa:SetE ntityPrope rty.Target Type> | |||||
| 293 | </mx swa:SetEnt ityPropert y> | |||||
| 294 | <mxs wa:GetEnti tyProperty Attribute =""leadid" " Entity=" "[InputEnt ities(&quo t;primaryE ntity" ;)]"" Enti tyName=""l ead"" Valu e=""[Creat eStep1_7]" "> | |||||
| 295 | <m xswa:GetEn tityProper ty.TargetT ype> | |||||
| 296 | <InArgumen t x:TypeAr guments="" s:Type""> | |||||
| 297 | <mxswa:R eferenceLi teral x:Ty peArgument s=""s:Type "" Value=" "mxs:Entit yReference "" /> | |||||
| 298 | </InArgume nt> | |||||
| 299 | </ mxswa:GetE ntityPrope rty.Target Type> | |||||
| 300 | </mx swa:GetEnt ityPropert y> | |||||
| 301 | <mxs wa:Activit yReference AssemblyQ ualifiedNa me=""Micro soft.Crm.W orkflow.Ac tivities.E valuateExp ression, M icrosoft.C rm.Workflo w, Version =5.0.0.0, Culture=ne utral, Pub licKeyToke n=31bf3856 ad364e35"" DisplayNa me=""Evalu ateExpress ion""> | |||||
| 302 | <m xswa:Activ ityReferen ce.Argumen ts> | |||||
| 303 | <InArgumen t x:TypeAr guments="" x:String"" x:Key=""E xpressionO perator""> SelectFirs tNonNull</ InArgument > | |||||
| 304 | <InArgumen t x:TypeAr guments="" s:Object[] "" x:Key=" "Parameter s"">[New O bject() { CreateStep 1_7 }]</In Argument> | |||||
| 305 | <InArgumen t x:TypeAr guments="" s:Type"" x :Key=""Tar getType""> | |||||
| 306 | <mxswa:R eferenceLi teral x:Ty peArgument s=""s:Type "" Value=" "mxs:Entit yReference "" /> | |||||
| 307 | </InArgume nt> | |||||
| 308 | <OutArgume nt x:TypeA rguments=" "x:Object" " x:Key="" Result"">[ CreateStep 1_6]</OutA rgument> | |||||
| 309 | </ mxswa:Acti vityRefere nce.Argume nts> | |||||
| 310 | </mx swa:Activi tyReferenc e> | |||||
| 311 | <mxs wa:SetEnti tyProperty Attribute =""regardi ngobjectid "" Entity= ""[Created Entities(& quot;Creat eStep1_loc alParamete r#Temp&quo t;)]"" Ent ityName="" phonecall" " Value="" [CreateSte p1_6]""> | |||||
| 312 | <m xswa:SetEn tityProper ty.TargetT ype> | |||||
| 313 | <InArgumen t x:TypeAr guments="" s:Type""> | |||||
| 314 | <mxswa:R eferenceLi teral x:Ty peArgument s=""s:Type "" Value=" "mxs:Entit yReference "" /> | |||||
| 315 | </InArgume nt> | |||||
| 316 | </ mxswa:SetE ntityPrope rty.Target Type> | |||||
| 317 | </mx swa:SetEnt ityPropert y> | |||||
| 318 | <mxs wa:Activit yReference AssemblyQ ualifiedNa me=""Micro soft.Crm.W orkflow.Ac tivities.E valuateExp ression, M icrosoft.C rm.Workflo w, Version =5.0.0.0, Culture=ne utral, Pub licKeyToke n=31bf3856 ad364e35"" DisplayNa me=""Evalu ateExpress ion""> | |||||
| 319 | <m xswa:Activ ityReferen ce.Argumen ts> | |||||
| 320 | <InArgumen t x:TypeAr guments="" x:String"" x:Key=""E xpressionO perator""> CreateCrmT ype</InArg ument> | |||||
| 321 | <InArgumen t x:TypeAr guments="" s:Object[] "" x:Key=" "Parameter s"">[New O bject() { Microsoft. Xrm.Sdk.Wo rkflow.Wor kflowPrope rtyType.Op tionSetVal ue, ""1"", ""Picklis t"" }]</In Argument> | |||||
| 322 | <InArgumen t x:TypeAr guments="" s:Type"" x :Key=""Tar getType""> | |||||
| 323 | <mxswa:R eferenceLi teral x:Ty peArgument s=""s:Type "" Value=" "mxs:Optio nSetValue" " /> | |||||
| 324 | </InArgume nt> | |||||
| 325 | <OutArgume nt x:TypeA rguments=" "x:Object" " x:Key="" Result"">[ CreateStep 1_8]</OutA rgument> | |||||
| 326 | </ mxswa:Acti vityRefere nce.Argume nts> | |||||
| 327 | </mx swa:Activi tyReferenc e> | |||||
| 328 | <mxs wa:SetEnti tyProperty Attribute =""priorit ycode"" En tity=""[Cr eatedEntit ies(" CreateStep 1_localPar ameter#Tem p")]" " EntityNa me=""phone call"" Val ue=""[Crea teStep1_8] ""> | |||||
| 329 | <m xswa:SetEn tityProper ty.TargetT ype> | |||||
| 330 | <InArgumen t x:TypeAr guments="" s:Type""> | |||||
| 331 | <mxswa:R eferenceLi teral x:Ty peArgument s=""s:Type "" Value=" "mxs:Optio nSetValue" " /> | |||||
| 332 | </InArgume nt> | |||||
| 333 | </ mxswa:SetE ntityPrope rty.Target Type> | |||||
| 334 | </mx swa:SetEnt ityPropert y> | |||||
| 335 | <mxs wa:CreateE ntity Enti tyId=""{x: Null}"" Di splayName= ""CreateSt ep1: Set f irst activ ity for le ad."" Enti ty=""[Crea tedEntitie s("Cr eateStep1_ localParam eter#Temp& quot;)]"" EntityName =""phoneca ll"" /> | |||||
| 336 | <Ass ign x:Type Arguments= ""mxs:Enti ty"" To="" [CreatedEn tities(&qu ot;CreateS tep1_local Parameter& quot;)]"" Value=""[C reatedEnti ties(" ;CreateSte p1_localPa rameter#Te mp")] "" /> | |||||
| 337 | <Per sist /> | |||||
| 338 | </Sequ ence> | |||||
| 339 | </mxswa: Workflow> | |||||
| 340 | </Activity >" | |||||
| 341 | }; | |||||
| 342 | _workflo wId = _ser viceProxy. Create(wor kflow); | |||||
| 343 | Console. Write("Cre ated workf low to cal l in Execu te Workflo w request, "); | |||||
| 344 | ||||||
| 345 | SetState Request se tStateRequ est = new SetStateRe quest() | |||||
| 346 | { | |||||
| 347 | Enti tyMoniker = | |||||
| 348 | new Entity Reference( Workflow.E ntityLogic alName, _w orkflowId) , | |||||
| 349 | Stat e = new Op tionSetVal ue((int)Wo rkflowStat e.Activate d), | |||||
| 350 | Stat us = new O ptionSetVa lue(2) | |||||
| 351 | }; | |||||
| 352 | _service Proxy.Exec ute(setSta teRequest) ; | |||||
| 353 | Console. WriteLine( "and activ ated."); | |||||
| 354 | } | |||||
| 355 | ||||||
| 356 | // / <summary > | |||||
| 357 | // / Deletes any entity records t hat were c reated for this samp le. | |||||
| 358 | // / <param n ame="promp t">Indicat es whether to prompt the user | |||||
| 359 | // / to delet e the reco rds create d in this sample.</p aram> | |||||
| 360 | // / </summar y> | |||||
| 361 | pu blic void DeleteRequ iredRecord s(bool pro mpt) | |||||
| 362 | { | |||||
| 363 | bool del eteRecords = true; | |||||
| 364 | ||||||
| 365 | if (prom pt) | |||||
| 366 | { | |||||
| 367 | Cons ole.WriteL ine("\nDo you want t hese entit y records deleted? ( y/n) [y]: "); | |||||
| 368 | Stri ng answer = Console. ReadLine() ; | |||||
| 369 | ||||||
| 370 | dele teRecords = (answer. StartsWith ("y") || a nswer.Star tsWith("Y" ) || answe r == Strin g.Empty); | |||||
| 371 | } | |||||
| 372 | ||||||
| 373 | if (dele teRecords) | |||||
| 374 | { | |||||
| 375 | SetS tateReques t setState Request = new SetSta teRequest( ) | |||||
| 376 | { | |||||
| 377 | EntityMoni ker = | |||||
| 378 | new En tityRefere nce(Workfl ow.EntityL ogicalName , _workflo wId), | |||||
| 379 | State = ne w OptionSe tValue((in t)Workflow State.Draf t), | |||||
| 380 | Status = n ew OptionS etValue(1) | |||||
| 381 | }; | |||||
| 382 | _ser viceProxy. Execute(se tStateRequ est); | |||||
| 383 | ||||||
| 384 | _ser viceProxy. Delete(Wor kflow.Enti tyLogicalN ame, _work flowId); | |||||
| 385 | _ser viceProxy. Delete(Lea d.EntityLo gicalName, _leadId); | |||||
| 386 | _ser viceProxy. Delete(Asy ncOperatio n.EntityLo gicalName, _asyncOpe rationId); | |||||
| 387 | Cons ole.WriteL ine("Entit y records have been deleted.") ; | |||||
| 388 | } | |||||
| 389 | } | |||||
| 390 | ||||||
| 391 | #e ndregion H ow-To Samp le Code | |||||
| 392 | ||||||
| 393 | #r egion Main method | |||||
| 394 | ||||||
| 395 | // / <summary > | |||||
| 396 | // / Standard Main() me thod used by most SD K samples. | |||||
| 397 | // / </summar y> | |||||
| 398 | // / <param n ame="args" ></param> | |||||
| 399 | st atic publi c void Mai n(string[] args) | |||||
| 400 | { | |||||
| 401 | try | |||||
| 402 | { | |||||
| 403 | // O btain the target org anization' s Web addr ess and cl ient logon | |||||
| 404 | // c redentials from the user. | |||||
| 405 | Serv erConnecti on serverC onnect = n ew ServerC onnection( ); | |||||
| 406 | Serv erConnecti on.Configu ration con fig = serv erConnect. GetServerC onfigurati on(); | |||||
| 407 | ||||||
| 408 | Exec uteWorkflo w app = ne w ExecuteW orkflow(); | |||||
| 409 | app. Run(config , true); | |||||
| 410 | } | |||||
| 411 | catch (F aultExcept ion<Micros oft.Xrm.Sd k.Organiza tionServic eFault> ex ) | |||||
| 412 | { | |||||
| 413 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 414 | Cons ole.WriteL ine("Times tamp: {0}" , ex.Detai l.Timestam p); | |||||
| 415 | Cons ole.WriteL ine("Code: {0}", ex. Detail.Err orCode); | |||||
| 416 | Cons ole.WriteL ine("Messa ge: {0}", ex.Detail. Message); | |||||
| 417 | Cons ole.WriteL ine("Plugi n Trace: { 0}", ex.De tail.Trace Text); | |||||
| 418 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 419 | null == ex .Detail.In nerFault ? "No Inner Fault" : "Has Inner Fault"); | |||||
| 420 | } | |||||
| 421 | catch (S ystem.Time outExcepti on ex) | |||||
| 422 | { | |||||
| 423 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 424 | Cons ole.WriteL ine("Messa ge: {0}", ex.Message ); | |||||
| 425 | Cons ole.WriteL ine("Stack Trace: {0 }", ex.Sta ckTrace); | |||||
| 426 | Cons ole.WriteL ine("Inner Fault: {0 }", | |||||
| 427 | null == ex .InnerExce ption.Mess age ? "No Inner Faul t" : ex.In nerExcepti on.Message ); | |||||
| 428 | } | |||||
| 429 | catch (S ystem.Exce ption ex) | |||||
| 430 | { | |||||
| 431 | Cons ole.WriteL ine("The a pplication terminate d with an error."); | |||||
| 432 | Cons ole.WriteL ine(ex.Mes sage); | |||||
| 433 | ||||||
| 434 | // D isplay the details o f the inne r exceptio n. | |||||
| 435 | if ( ex.InnerEx ception != null) | |||||
| 436 | { | |||||
| 437 | Console.Wr iteLine(ex .InnerExce ption.Mess age); | |||||
| 438 | ||||||
| 439 | FaultExcep tion<Micro soft.Xrm.S dk.Organiz ationServi ceFault> f e = ex.Inn erExceptio n | |||||
| 440 | as Fau ltExceptio n<Microsof t.Xrm.Sdk. Organizati onServiceF ault>; | |||||
| 441 | if (fe != null) | |||||
| 442 | { | |||||
| 443 | Consol e.WriteLin e("Timesta mp: {0}", fe.Detail. Timestamp) ; | |||||
| 444 | Consol e.WriteLin e("Code: { 0}", fe.De tail.Error Code); | |||||
| 445 | Consol e.WriteLin e("Message : {0}", fe .Detail.Me ssage); | |||||
| 446 | Consol e.WriteLin e("Plugin Trace: {0} ", fe.Deta il.TraceTe xt); | |||||
| 447 | Consol e.WriteLin e("Inner F ault: {0}" , | |||||
| 448 | nu ll == fe.D etail.Inne rFault ? " No Inner F ault" : "H as Inner F ault"); | |||||
| 449 | } | |||||
| 450 | } | |||||
| 451 | } | |||||
| 452 | // Addit ional exce ptions to catch: Sec urityToken Validation Exception, ExpiredSe curityToke nException , | |||||
| 453 | // Secur ityAccessD eniedExcep tion, Mess ageSecurit yException , and Secu rityNegoti ationExcep tion. | |||||
| 454 | ||||||
| 455 | finally | |||||
| 456 | { | |||||
| 457 | Cons ole.WriteL ine("Press <Enter> t o exit."); | |||||
| 458 | Cons ole.ReadLi ne(); | |||||
| 459 | } | |||||
| 460 | } | |||||
| 461 | #e ndregion M ain method | |||||
| 462 | } | |||||
| 463 | } | |||||
| 464 | //</snippe tExecuteWo rkflow> |
Araxis Merge (but not the data content of this report) is Copyright © 1993-2016 Araxis Ltd (www.araxis.com). All rights reserved.