Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Questions on Business Maps
Since I think this module is going to play a big role I'd like to get a good understanding. Let me just fire some questions from reading the docs:

SELECT accountid,accountname
FROM vtiger_account
INNER JOIN vtiger_crmentity ce ON ce.crmid=vtiger_account.accountid
WHERE ce.deleted=0 AND vtiger_account.accountid =?
<return>accountname</return>    {count|recordset}

OK, this is a query sure enough. You create it as an entity since I think Business Maps follows the basic entity GUI model. I write the code into the entity and then... What's the event it responds to? What's done with the return value? Can this be used in a workflow for instance?

Next one: the field mapping.

I see:

    <originid>22</originid>  {optional}

This is obvious enough. But the origin id, this is the module's ID right? What's called tabid in the database?

Then this part from fieldmapping:
      <fieldname>subject</fieldname>   {destination field on invoice}
      <fieldID>999</fieldID>  {optional}
      <Orgfields>  {if more than one is present they will be concatenated with the delimiter}
          <OrgfieldName>_FromSO</OrgfieldName>  {this is a constant string}

So the <fieldname> is the name of the field from the target module, then subsequent fields in this <field> set will be filled with the concatenated string using the delimiter. How de the constants work? Is this case only one. Are they PHP constants? Is there a list of these constances as a reference? Is the event automatically triggered by the name ({originalModule}2{TargetModule})?

Since I am also to investigate the GlobalVariable module some more (I just am too busy, still don't know what it does exactly, probably set global variables) I'd like to shine dome light on this:

PHP Code:
$cbMapid GlobalVariable::getVariable('BusinessMapping_SalesOrder2Invoice'cbMap::getMapIdByName('SalesOrder2Invoice'));
  if (
$cbMapid) {
$cbMap cbMap::getMapByID($cbMapid);
$focus->column_fields $cbMap->Mapping($so_focus->column_fields,$focus->column_fields);
  } else { 

So I create a global variable called BusinessMapping_{my_map_name} and paste in this code? I'm thinking a bit in loops here, probably my bad...
First, each mapping type has it's own functionality and is used/launched depending on that. For example, the first one you indicate above is a Condition Query mapping, this one can be used as part of a Record Access Control mapping or simply can be used by your code whenever you need to make a decision. So let's imagine that you are creating some functionality that requires a set of account IDs, you could use the Condition Query mapping to get that set of Accounts, that way you don't have to create any special interface or functionality to get those accounts.

Yes, the origin id is the tabid. Truth is that none of the mappings I have created use it, you can safely ignore it, just put the module name.

Constants are simply text, nothing more, whatever you put inside the OrgfieldName directive will be concatenated. They are not calculated nor related to PHP in any way, just simple text.

Yes, it is actually triggered by the string {originalModule}2{TargetModule}, the code looks for a mapping with this name and if it finds it applies the indicated mapping. This is incredibly powerful to fill in fields. The typical: "set invoice due date to today plus 30 days" is a breeze with these mappings.

Global Variables are another incredibly powerful concept coreBOS has introduced. The idea is that you adapt the functionality of the code depending on the value of a variable set by the user. For example, imagine that we moved the list_max_entries_per_page variable which is now hardcoded in the file into a global variable. Now someone could go to the global variable module and create a record with a new value for the maximum number of records that will appear per page in the list view. Now that is easy enough, but the real power comes when you see that a global variable depends on the user defining the variable and the module it is being defined for, so you could define a list_max_entries_per_page of 20 for accounts and another of 100 for invoices while another user would define his own list_max_entries_per_page depending on his needs.

Then there is some additional magic whereas an admin user could block and make default or mandatory a variable for all users.

Really powerful!

Now your last code above. Instead of directly looking for a field mapping called 'SalesOrder2Invoice' we look for the mapping on the global variable module first, if it isn't found we will default to 'SalesOrder2Invoice' value. With this we accomplish that EACH user can have their own field mapping, so if one user need to set the Invoice due date to 30 days, while another needs it set to 90 days, they can do that by defining their own global variable.

Have a read at all that and keep asking.... :-)

Forum Jump:

Users browsing this thread: 1 Guest(s)