====== (Field) Mapping Business Mapping ====== This business rule serves the purpose of filling in fields of a new record when coming from another module's record or setting default values for the module you are creating. For example, when creating an Invoice from a SalesOrder or an Opportunity from a Contact. When creating a new record you always have access to all the fields of the current user using the FIELD or TEMPLATE types. For example: $(assigned_user_id : (Users) first_name) It will permit you to define what values you want to copy from the origin module or simply what values you want to set by default when creating in the way. The accepted format is: SalesOrder Invoice subject {destination field on invoice} {if more than one is present they will be concatenated with the delimiter} subject 634 sostatus 778 _FromSO {this is a constant string} CONST ; true|false {optional: used for integration mapping between two systems} description {destination field on invoice} {if more than one is present they will be concatenated with the delimiter} $(assigned_user_id : (Users) first_name) FIELD $(assigned_user_id : (Users) last_name) FIELD The user assigned to the Sales Order is: $(assigned_user_id : (Users) first_name) $(assigned_user_id : (Users) last_name) {this is a constant string} TEMPLATE account_id RULE business rule name or ID - due_date {destination field on invoice} add_days(get_date('today'), 30) EXPRESSION ..... The name of the mapping must follow a specific format which is {OriginModule}2{TargetModule} you must create the mapping exactly with that name and the module names must be exactly their internal module name. If you want to have more than one mapping that will be applied depending on the user you must also create a new entry in the Global Variable name picklist called BusinessMapping_{OriginModule}2{TargetModule} and then define a Global Variable of this type and select the corresponding Business Mapping. For example, if you create a Mapping called //Contacts2Potentials// and set it's mapping to the one below, you will get the name set to the contact's name, the closing date set to 30 days from now and the sales stage set to Qualifying. Then call the create page of Potentials from a link passing in the variable **cbfromid** or from a related list, which already has this variable. Contacts Potentials potentialname firstname lastname closingdate add_days(get_date('today'), 30) expression sales_stage Qualification CONST Another example for User default values: Users Users currency_grouping_pattern 123456789 CONST currency_decimal_separator . CONST QLTQ QLTQ CONST ALVT ALVT CONST tagcloudview false CONST showtagas vring CONST You can [[en:adminmanual:businessmappings:store:contact2accounts|see an example of converting a Contact into an Account in the Business Mapping Store]]. And there is an explanation and [[http://discussions.corebos.org/thread-338-post-1723.html#pid1723|small example of Invoice default values here.]] Another [[http://discussions.corebos.org/thread-346-post-1772.html#pid1772|example with Help Desk default values in the forum.]] ===== Rule Directive ===== The rule directive will permit us to launch a [[en:devel:corebos_rules|coreBOS Business Rule]] and save the result in the field. This opens the possibilities to launch a query, a workflow expression or a decision table. You can accomplish the expression and template features with the Rule as it can do that and more. For example, we may be given a code that we have to search in another module to save a value that comes from there. In this case, we need to launch a query so we would set up a Business Map (Rule) of type Condition query with something like this: SELECT contactid FROM vtiger_contactdetails JOIN vtiger_contactscf on vtiger_contactdetails.contactid = vtiger_contactscf.contactid where cf_1518=? Let's suppose we called this business map "getContactFromSeller", then we would add the directive: contact_id RULE getContactFromSeller ===== Accessing via web service ===== This type of map can be processed using the **ProcessMap** end-point