Yes, it is possible with studio and related fields, as long as the relations are setup correctly. To understand the logic behind this, we must understand that
the Contacts model is linked to the Sales model out-of-the-box. This is why we
can see all the Sales Orders on the Contact form in the stat
buttons. Once you establish a connection between 2 models, you can pull
information from one to the other through Related Fields, as long as the path
is correct. Following are step-by-step instructions on how to establish this.
- Make
sure you are in Debug (developer) mode. Open Studio while in the Contacts form
view.
- Drag and drop a new DateTime field anywhere on
the form view. By default, this is a brand-new field and is not related to
anything.
- Name this field
“Latest Sales Order Date” or anything along those lines. This will be the field
that will display the last order date once we configure it.
- Click on the new field
and click the “More” option on the bottom left toolbar.
- This will open field
properties. Under “Related Field” input this – “sale_order_ids.date_order”. To
explain what this means - we are relating it to the Order Date (date_order)
field on the Sales Order link in contacts (sale_order_ids).
- Close Studio and
refresh your page.
You have now created a DateTime
field which is linked to the Order Date field in Sales Orders. Since Sales
Orders are sorted by default by Order Date, it will always pull the latest
order date. You can now Filter and Groupby this new field and setting a Filter
that displays contacts with latest order date before a particular date will
give you a list of contacts that haven’t purchased from you in a while.
Limitations-
- If you have custom
sorting on your Sales Orders, this will not work. It always pulls the date of
the first Sale Order it finds, so it is imperative that we have the latest Sale
Order first. The sorting needs to be by Order Date.
- This new field will
NOT auto-populate all the contacts for existing Sales Orders. In other words,
it is not retrospective. It will only start populating the Dates for new Sales
Orders created moving forward. This is an important point to note, as it will
be blank after you follow the above steps. But when you create the next Sale
Order, it will populate. Over time, it will self-correct to populate values for
your contacts.