User Tools


Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
en:adminmanual:businessmappings:duplicaterecords [2017/06/16 16:22]
joebordes [Duplicating second level records]
en:adminmanual:businessmappings:duplicaterecords [2017/06/16 16:27] (current)
joebordes [Duplicating second level records]
Line 56: Line 56:
 If you need to duplicate also the relations on those records, or even go lower in the relation tree, we need to do some additional work. If you need to duplicate also the relations on those records, or even go lower in the relation tree, we need to do some additional work.
  
-In order to completely duplicate a record we must know the CRMID of the record. This is the record that is launching the workflow.+In order to completely duplicate a recordwe must know the CRMID of the record. This is the record that is launching the workflow.
  
-If we define another workflow, with a duplicate record task, on one or more of the related modules we may think that it will launch when the parent duplicate tasks creates a record in this module. In other words, let's suppose that we have a duplicate record task on Projects and we want to duplicate all the Project Tasks with the relations it may have. So we add another duplicate record task on the Project Tasks module. What we end up with is two duplicate Project Tasks with none of the related information the original one had. This is wrongbut makes sense. Let me try to explain.+If we define another workflow, with a duplicate record task, on one or more of the related modules we may think that it will launch when the parent duplicate tasks creates a record in this module. In other words, let's suppose that we have a duplicate record task on Projects and we want to duplicate all the Project Tasks with the relations it may have. So we add another duplicate record task on the Project Tasks module. What we end up with is two duplicate Project Tasks with none of the related information the original one had. This is wrong but makes sense. Let me try to explain.
  
-The duplicate task on Project starts creating new dulpicate ​Project Tasks after duplicating the Project record that launched the workflow. This process creates a new Project Task and relates it to the new duplicated Project. This save process launches the duplicate record task on the newly created Project Task record which is duplicated, NOT the original Project Task which the first task dulpicated ​but the SECOND, duplicate Project Task is the one that launches the workflow. That is why we end up with two records with no related records.+The duplicate task on Project starts creating new duplicate ​Project Tasks after duplicating the Project record that launched the workflow. This process creates a new Project Task and relates it to the new duplicated Project. This save process launches the duplicate record task on the newly created Project Task record which is duplicated, NOT the original Project Task which the first task duplicated ​but the SECOND, duplicate Project Task is the one that launches the workflow. That is why we end up with two records with no related records.
  
 To fix this we must add a new field on the Project Task module (and on all the related modules we want to duplicate correctly). This field must be called **//​isduplicatedfromrecordid//​**. It will hold the CRMID of the original record the duplication started from and will be used to get the relations and launch the workflow correctly. To fix this we must add a new field on the Project Task module (and on all the related modules we want to duplicate correctly). This field must be called **//​isduplicatedfromrecordid//​**. It will hold the CRMID of the original record the duplication started from and will be used to get the relations and launch the workflow correctly.
Line 80: Line 80:
  
 if($module) { if($module) {
-    $blockInstance ​VTiger_Block::getInstance('​LBL_OPPORTUNITY_INFORMATION',​$module);+    $blockInstances ​Vtiger_Block::getAllForModule($module); 
 +    $blockInstance = reset($blockInstances);​ // get first block
  
  if($blockInstance) {  if($blockInstance) {