The purpose of this mapping is to define the structure of a master-detail module so it can be used to construct a special module editor.
The inventory modules are examples of master-detail modules, there is the first section of “header” data followed by a set of lines that depend on it (product lines in this case).
With this mapping, we can specify the relation between parent and child modules and also the fields that we should show in the list and detail view of the dependent module. We also can detail the aggregation fields that need to be calculated and shown.
We are going to use the Master-Detail Business Maps on the Quotes Module. So, open up any quote you like.
Also, we will open another tab with the Inventory Details related to this Quote.
Basically, the idea is that the Inventory Details Module records automatically all the lines in each Inventory record, for example, quotes, sales orders, purchase orders, invoices are inventory modules because they are Master-Detail in the sense that there’s a Master Record like a header and then we have a bunch of products and service lines which are the details related to this module.
As you can see in our case the quote we picked has 7 product lines and each one of these product lines has a set of fields, for example, we have how many items of that product we have on stock, how many did we put in this quote, the list price, the unit price, the discount, total after discount and total for the product line.
This means that in our Inventory Detail module for this Quote, we have exactly those seven lines but with more detail.
If we open the first one in a new tab we can see that we have the same product and some other information related to the organization the quote is related to, if related to any contact, this product vendor, the line item ID, the sequence number. To sum up we have everything we need to get all the details of that product line.
So basically we have a whole bunch of fields here, that are coming from those product lines and they are synchronized at the same time.
What we want to do now is add the Units Delivered/Received on the Quote. What we mean is that in many situations you are going to want to have on the product lines in the quote that information. So that we look at the quote we want to see the units that have been delivered or received.
To do that we have a Master-Detail Business Map. The goal of this mapping is to be able to define the details, the fields and the configuration options of the detail lines in a Master-Detail Module.
The example in our case would be that we want to define which fields we want to see on those lines.
Originally the master-detail mapping was created for development purposes. The native master-detail inventory modules that we have in coreBOS, inherited for vTiger have enhanced a lot. They are cumbersome and non-standard; They don’t follow the rules and is hard to program on them. Basically, we respect them because they are working. So we have fixed and enhanced them by adding some features.
We use the Master-Detail Mapping for the possibility to define what fields we want on those detail lines so that the client or the user can change the visual interface very easily with the mapping.
Let’s get into our example. We are going to use this default code that we have here.
<map> <originmodule>Quotes</originmodule> <targetmodule>InventoryDetails</targetmodule> <linkfields> <originfield>lineitem_id</originfield> <targetfield>lineitem_id</targetfield> </linkfields> <sortfield>sequence_no</sortfield> <detailview> <fields> <field> <fieldtype>corebos</fieldtype> <fieldname>units_delivered_received</fieldname> <editable>1</editable> <mandatory>1</mandatory> <hidden>0</hidden> </field> <field> <fieldtype>corebos</fieldtype> <fieldname>cost_price</fieldname> <editable>1</editable> <mandatory>1</mandatory> <hidden>0</hidden> </field> </fields> </detailview> </map>
Copy this mapping and jump over to the application to see how the mapping works. Here is the Business Mapping Module.
Click on the plus icon to create a new business map.
Firstly, let’s write the name of the business mapping: QuotesInventoryDetails. It is an important step because that is how coreBOS detects that this Master-Detail Mapping should be applied to Quotes in our case or whatever module in other examples. In the Map type, we choose the Master-Detail Layout option and on the Target Module, we choose Quotes.
Paste the code on the Content section. Now let’s have a look at the mapping code.
In the first lines, it says that is a map, that the origin module is Quotes and the Target module is Inventory Details. The next two lines answer the question:" What fields link the Quote Module and Inventory Details module?" This is the lineitem_id field. Then we want to sort these records on screen by the sequence number. So now let’s jump into the detail view. What do we want to see on those detail lines? The field_type is coreBOS and the name of the field is the units_delivered_received, which is the name of the field on the Inventory Details. It’s editable, mandatory and not hidden. We can also put some hidden fields if needed. Another one is also coreBOS. This is a cost price field editable, mandatory and not hidden.
Save the Mapping and jump back to the Quotes Module. Now you can see that there are added the Units Delivered/Received and the Cost Price on each line.
Now if we edit any of these lines, for example, we add the cost price here on the quote, the change will be displayed on the corresponding inventory details record. So, as a result, with this mapping, we were able to add information fields to edit and save very easily on each product/service line of the quote module or any other inventory module.