Sei sulla pagina 1di 3

How to: Windows Workflow Foundation in POS

Further reading
Microsoft Dynamics AX 2012 for Developers [AX 2012] SDK Download RunOperation Method

Tutorial
AX Retail Point of Sale allows partners to customize services. Partners can programmatically invoke the same core operations users invoke by pressing a button in the UI. These operations can further be described by a Windows workflow. 1. Create a new Windows workflow project in Visual Studio. 2. Add a new Code Activity (see ItemSaleActivity.cs). 3. Add a new Activity (see ItemSale.xaml). a. The ItemSale.xaml expects an ItemId as an argument and has a default value of 0113. 4. Build your project and put both the dll and the xaml file in your desired folder. 5. On the main screen, click Tasks then right click on a button and change the action to Windows workflow foundation, set the Path field to reflect the location of your xaml file. 6. To run the workflow, just click the newly added button.

Example
ItemSaleActivity.cs
public class ItemSaleActivity : NativeActivity { // Define an activity input argument of type string public InArgument<string> ItemId { get; set; } protected override void Execute(NativeActivityContext context) { IApplication application = context.GetExtension<IApplication>(); if (application != null) { string itemId = context.GetValue(this.ItemId); application.RunOperation(PosisOperations.ItemSale, itemId); } } }

ItemSale.xaml
<Activity mc:Ignorable="sap" x:Class="WorkflowDemo.ItemSale" local:ItemSale.itemId="0113" xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities" xmlns:local="clrnamespace:WorkflowDemo;assembly=WorkflowDemo" xmlns:mc="http://schemas.openxmlformats.org/markupcompatibility/2006" xmlns:mv="clr-namespace:Microsoft.VisualBasic;assembly=System" xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:s1="clr-namespace:System;assembly=System" xmlns:s2="clr-namespace:System;assembly=System.Xml" xmlns:s3="clrnamespace:System;assembly=System.Core" xmlns:sa="clrnamespace:System.Activities;assembly=System.Activities" xmlns:sad="clrnamespace:System.Activities.Debugger;assembly=System.Activities" xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation" xmlns:scg="clrnamespace:System.Collections.Generic;assembly=System" xmlns:scg1="clrnamespace:System.Collections.Generic;assembly=System.ServiceModel" xmlns:scg2="clrnamespace:System.Collections.Generic;assembly=System.Core" xmlns:scg3="clrnamespace:System.Collections.Generic;assembly=mscorlib" xmlns:sd="clrnamespace:System.Data;assembly=System.Data" xmlns:sl="clrnamespace:System.Linq;assembly=System.Core" xmlns:st="clrnamespace:System.Text;assembly=mscorlib" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <x:Members> <x:Property Name="itemId" Type="InArgument(x:String)" /> </x:Members> <sap:VirtualizedContainerService.HintSize>240,240</sap:VirtualizedContainerService.HintSize> <mva:VisualBasic.Settings>Assembly references and imported namespaces for internal implementation</mva:VisualBasic.Settings> <local:PosOperationActivity sad:XamlDebuggerXmlReader.FileName="ItemSale.xaml" sap:VirtualizedContainerService.HintSize="200,200" ItemId="[[itemId]]" /> </Activity>

Potrebbero piacerti anche