Walkthrough: Adding Properties to a Sales Order
Important
This content is archived and is not being updated. For the latest documentation, see Microsoft Dynamics 365 product documentation. For the latest release plans, see Dynamics 365 and Microsoft Power Platform release plans.
Applies To: Microsoft Dynamics AX 2012 R3, Microsoft Dynamics AX 2012 R2
You can customize sales order properties to send additional data from your online store to Microsoft Dynamics AX to meet the needs of your business processes.
The starter store has sales order properties that you can use to capture data during order transactions. You can extend the sales order properties to send additional data from your online store to Microsoft Dynamics AX during order transactions. For example, you could add an attribute called GiftWrap to indicate that an item should be wrapped.
To customize sales order properties:
Create an attribute.
Add the attribute to an attribute group.
Assign the attribute group to your online store.
Set the attribute on a sales order.
Creating an Attribute
To create an attribute, you must define an attribute type and then assign the attribute type to your new attribute. In this example, you use an attribute type that is included in Microsoft Dynamics AX. For more information about attributes, see Set up attributes and attribute types.
To create an attribute
In Microsoft Dynamics AX, click Product information management > Setup > Attributes > Attributes.
Click New. Enter the following values:
Property
Value
Name
GiftWrap
Friendly name
Gift wrap
Attribute type
StringDomain
Adding the Attribute to an Attribute Group
After you define your attribute, you can add it to an attribute group. For more information about attribute groups, see Set up retail attribute groups.
To create an attribute group and add your attribute
Click Product information management > Setup > Attributes > Attribute groups.
Click New. Enter the following values:
Property
Value
Name
SPSalesOrderGroup
Friendly name
Sales order attribute group
Description
Sales order attribute group
In Attributes, click Add.
Select GiftWrap, and then click Select.
Click OK.
Assigning the attribute group to your online store
After you create your attribute group, assign it to your online store. For more information, see Set up an online store.
To assign an attribute group to your online store
Click Retail > Common > Retail channels > Online stores. In the Online stores list, double-click your store.
Click the Set up tab and then click Sales order attributes.
In Channel attribute groups, click New.
In Name, select SPSalesOrderGroup.
Setting the attribute on a sales order
You can add the attribute to a sales order by adding business logic in the commerce runtime. Add the following code to add the attribute to the cart, save the cart, and then create a sales order from the cart.
Var cart = orderManager.GetCart(cartId, accountNumber, false);
cart.AttributeValues.Add(new AttributeTextValue { Name = "GiftWrap", TextValue = "Yes" });
orderManager.SaveCart(cart);
orderManager.CreateOrderFromCart(…);
Next Steps
After you create a sales order on the commerce runtime, you can view the new attribute in Microsoft Dynamics AX.
To view the attribute in Microsoft Dynamics AX
In Microsoft Dynamics AX, click Retail > Periodic > Data distribution > Distribution schedule. Run the job P-0001_OC to run POS transactions in the online channel.
Click Retail > Periodic > Synchronize online orders to create a sales order in Microsoft Dynamics AX.
Click Accounts receivable > Common > Sales orders > All sales orders. Click the Retail tab, and then click Retail attributes. You should see the attribute you created.