Product properties are attributes that represent a single detail of a product like its size, color, component, and so on (For details see: Use properties to describe a product).
In this article, we will detail the behavior behind product properties, how to access them, and how to add them to your templates using DocumentsCorePack.
Accessing and Adding Product Properties
Product properties behave differently from normal fields. To support such fields, so-called virtual fetches are used. Because of this, they cannot be accessed like other fields, i.e., they cannot be found in the “Standard” tab in the Template Designer, and they cannot be added manually to a table. Instead, the “Properties” look-up will be added automatically to a table under the “Additional” tab for tables where products are listed as line items:
In the above example, the look-up is displayed under the Quote Line table, but this look-up will also be added automatically to similar tables, such as Opportunity Line, Invoice Line, and Order Line.
When the “Properties” look-up is expanded, a list of all available product properties will be displayed. This list includes every product property from each product that has them. To add a specific field from a property, click on the look-up for the desired property and select the needed field.
Important: Normally, the Template Designer only lists the fields specific to an entity. In this case, the Template Designer lists all product properties across all products since each product can have differing properties. Due to this, users must know ahead of time which properties will be needed for their template. Otherwise, an irrelevant property can be added, leaving a blank spot in the resulting document (see below).
Example
In our environment, we have a Quote that has a few products listed under Quote Line. Each product has at least one property.
For our template, we want to create a Quote template that lists the products and their respective properties. To begin with, we create a template with Quote as the base entity and create a relationship to Quote Line. Once that is done, you will notice the “Properties” look-up has been added to the Quote Line table (as shown in Figure 1 above).
We can create a Quote Line table based on the name field of the entity. We will leave an extra column for our product properties.
Under the “Properties” look-up, we can find the product properties we need. Since we want the name and value of these properties, we expand the look-up and include the “Name” and “Value” field under each property.
If we were to generate a document based on this template right now, we would find that our products and their properties would be listed.
Avoiding empty lines
This table is not quite finished. The resulting table still has some empty lines as a result of every property being listed for each product. To work around this, you can insert the product property fields within Microsoft Word’s own IF fields (NOTE: DCP’s own Condition fields will not work with product properties).
Be sure to keep the structure of the IF field in mind. We only want each property to be displayed if the property exists for a given product. In our case, the structure of the IF field would look like this:
{ IF “PROPERTY_NAME” = “” “” “PROPERTY_NAME: PROPERTY_DYNAMICPROPERTYOPTIONNAME” \* MERGEFORMAT }
Helpful Resources:
That’s it! If you would like to give us any feedback, please contact us by sending an email to support@mscrm-addons.com.