====== Master Detail Mapping ====== The purpose of this mapping is to define the structure of a master-detail relationship between two modules that will permit us to construct a special module editor. The inventory modules are examples of master-detail modules, there is a 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 relationship between parent and child modules * the fields that we should show in the list and detail view of the dependent module. if the field is a coreBOS field, the internal fieldID and column name will be returned with the map definition * the aggregation fields that need to be calculated and shown The full syntax of the map looks like this: Master Module Detail Module id field of the master module id field of the detail module sequence field on the detail module to sort the records translatable label of the header bar of the detail section standard-sprite/svg/symbols.svg#opportunity 1 if an expand all button is present 1 if an add button is present URL to get the rows to show 1 if a move up button is present on the line 1 if a move down button is present on the line 1 if the records can be deleted from the list view 1 if the records can be edtted from the list view corebos.related ... ... 0 0 0 type of editor to show in the inline edit of the cells if the column is sortable default direction of sort corebos codigo 1 1 0 corebos cantidad 1 1 0 corebos tipodescuento 1 1 0 corebos descuento 1 1 0 corebos dtomontante 1 1 0 corebos linetotal 1 1 0 corebos.related ... codigo 0 0 0 0 0 corebos codigo 1 1 0 corebos cantidad 1 1 0 corebos tipodescuento 1 1 0 corebos descuento 1 1 0 corebos linetotal 1 1 0 top true aggregation callresponse count linetotal dqcilinesnum top aggregation callresponse sum linetotal dqcilinestotal top true aggregation callresponse sum dtomontante dqcidescuento left true **Other information returned with the map** Besides the information introduced in the map, the programmer will also get: * **mapnameraw** the map name * **mapname** the map name with no spaces nor special characters in lower case (for HTML ID) * arrays of fields * **viewfields** fieldIDs of the fields to show * **viewfieldnames** names of the fields to show * **editfields** fieldIDs of the fields to edit * **editfieldnames** names of the fields to edit * **targetmoduleidfield** the corebos module ID field for the Detail module Inventory type Master-Details need an interface like this: {{ :en:adminmanual:businessmappings:masterdetaillistview.png |Inventory type Master-Details}} Support/History type Master-Details need an interface like this: {{ :en:adminmanual:businessmappings:gitlabmarkdown.png |Support/History type Master-Details}} ====== Generic Master Detail ====== This map can be used as infrastructure for you to create your own editor, but coreBOS will give you a generic editor if you create the map between two modules with a one-to-many (1:m) relation and create the necessary map and actions. For this to work, we have to follow some rules and set up two actions. * In the business map record, the **target module** picklist field **MUST** be the detail module * The **sortfield MUST** be an integer * You must create a business action with the Master-Detail widget, something like this block://MasterDetailGridLayoutWidget:modules/Utilities/MasterDetailGridLayoutWidget.php:PID=$RECORD$&mapname=Project-ProjectTask The link type is **DETAILVIEWWIDGET** and the module it is on has to be the Master module (Projects in the example above) * You must create a business action that loads the Master-Detail javascript code, something like this include/js/masterdetailgrid.js The link type is **HEADERSCRIPT** and the module it is on has to be the Master module (Projects in the example above) * List view datasource: the special value **corebos** means that the detail is a normal coreBOS module * icon: in the header of the master-detail block we follow the LDS guidelines and prefix the title with an icon if given here. You can select any valid icon from LDS [[en:adminmanual:businessmappings:CreatingGenericEditor|Read about the Making of the Generic Editor]] ====== Master Detail on Inventory Modules ====== There is a special implementation where this mapping can be used. The four existing inventory modules will look for specific master-detail mapping with the InventoryDetail module and, if found, they will permit you to edit fields on that module in the product lines. This makes it easy to track a serial number, add an expiration date, track units served, or calculate costs for each line. As usual with Business Mappings the name is the means that the system uses to detect the ones to apply and, in this case, the name must be **{ModuleName}InventoryDetails** Here is a Master-Detail mapping for the PurchaseOrder module (PurchaseOrderInventoryDetails) that will permit you to edit units_delivered_received, a custom field and the product cost: PurchaseOrder InventoryDetails lineitem_id lineitem_id sequence_no corebos units_delivered_received 1 1 0 corebos cf_795 1 1 0 corebos cost_price 1 1 0 See this video for a demonstration: {{youtube>zfuEuGUhKm0}}