One Module field can reflects its value on other modules

hi,
I have created a Custom field ’ Credit On Hold’, in Accounts module, howto reflect its value to ‘Accounts’ related records of Quote, Invoice and opportunity. modules.

When a user modifies the ‘Credit On Hold’, its value should be displayed in Quote, Invoice and Opportunity.

What is the best approach to achieve above requirement.

-Regards,
Fareed Ahmed.

That can be achieved via Workflows from with in the UI environment or from LogicHooks programed at the back end.

To learn more about Workflow check here:
https://docs.suitecrm.com/user/advanced-modules/workflow/
https://docs.suitecrm.com/user/advanced-modules/workflow-calculated-fields/#_substring

For more info on LogicHooks please check here:
https://docs.suitecrm.com/developer/logic-hooks/

Thanks,

AlxGr

Hi,

You can do this from “after_retrieve” and “process_record” logic look.

For Detail View use the after_retrieve.

For Subpanel View and list view you can use the process_record logic hook.

Steps to Follow:-

  1. Create an “after_retrieve” hook to pull the target field data on the detail view.
  2. Create a non-db field in module B and put above field value inside this field.
  3. Drag and drop your field in detailView.
  4. If you are looking to show this field value inside list view/pop up or sub panel, you need to create a “process_record”. just call the same class and function.

Thank You!

1 Like

Hi Fareed,

i would do this by extending vardefs / creating a related field in Contacts / Invoices / Opportunities.
Look at the vardefs how account_name is related, copy the definition and change the id i.e Account_CreditonHold.
Then you can use it in List/Edit/Detail Views and subpanel.

kind regards.

*** custom/Extention/modules/Contacts/Vardefs/vardefs.ext.php

   
$dictionary["Contacts"]["fields"]["account_credit_on_hold'"]  =
                    'name' => 'account_credit_on_hold',
                    'rname' => '<your account field name for credit on hold>',
                    'id_name' => 'account_id',
                    'vname' => 'LBL_ACCOUNT_CREDITONHOLD', //ADD this to your language file
                    'join_name' => 'accounts',
                    'type' => 'relate',
                    'link' => 'accounts',
                    'table' => 'accounts',
                    'isnull' => 'true',
                    'module' => 'Accounts',
                    'dbType' => 'decimal',
                    'len' => '16',
                    'precision' => '2',
                    'source' => 'non-db',
                    'unified_search' => false,
                ),

Add this also to the other modules.

1 Like

Hi,
Thank you for the support .
but advised solution is not successful , following steps has applied

  1. Create new field in Accounts module name 'credit_hold_c type ‘checkbox’
  2. create new file in contact module ‘custom/Extension/modules/Contacts/Ext/Vardefs/vardefs.ext.php’
  3. used following code
  $dictionary['Contact']['fields']['acc_credit_hold_c']  =array(
                    'name' => 'acc_credit_hold_c',
                    'rname' => 'credit_hold_c',
                    'id_name' => 'account_id',
                    'vname' => 'LBL_ACC_CREDITONHOLD', //ADD this to your language file
                    'join_name' => 'accounts',
                    'type' => 'relate',
                    'link' => 'accounts',
                    'table' => 'accounts',
                    'isnull' => 'true',
                    'module' => 'Accounts',
                    'dbType' => 'bool',
              
                    'source' => 'non-db',
                    'unified_search' => false,
                    'studio' => 'visible',
  );
?>

the issue is that account ‘credit_hold_c’ dose not reflect on contact module and in contact edit view give option to select account instant of 'checkbox;.

-Fareed Ahmed,

hi ashish,

after_retrieve failed in Invoice & Quote module it it works fine in opportunity and contact.

custom/Extension/modules/AOS_Quotes/Ext/Vardefs/vardefs.ext.php

<?php

$dictionary['AOS_Quotes']['fields']['credit_hold_c']= array(
    'name' => 'credit_hold_c',
    'vname' => 'LBL_CREDIT_HOLD_C',
    'type' => 'bool',
    'source' => 'non-db',
    'studio' => 'visible',
  );
  
 ?>

======================================================
custom/modules/AOS_Quotes/logic_hooks.php

<?php

   $hook_version = 1;
   $hook_array = Array();
   $hook_array['after_retrieve'] = Array(); 
  $hook_array['after_retrieve'][] = Array(77, 'creditonhold3', 'custom/modules/AOS_Quotes/creditonhold3.php','creditonhold3', 'ShowLog');  

  
?>

======================================================
custom/modules/AOS_Quotes/creditonhold3.php

 <?php 

#if (!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

require_once('modules/Opportunities/Opportunities.php'); 


 
 

class creditonhold3

{ 

protected static $fetchedRow = array(); 

public function GetValue($Bean, $event, $arguments) 

{ 

$o=new Opportunity();
 
$o->retrieve($Bean->opportunity_id); //check but I believe that's the account id relate field in the case 

$a = new Account();

$a->retrieve($o->account_id_c)

$field_one_value = $a->credit_hold_c; 

$Bean->credit_hold_c = $field_one_value; 

$GLOBALS['log']->fatal("fareed:GetValue::Opp".$Bean->name);  

$GLOBALS['log']->fatal("fareed:GetValue::ACC".$a->name);  

$GLOBALS['log']->fatal("fareed:GetValue::CreditOnHold".$field_one_value);  

} 

public function ShowLog($Bean, $event, $arguments){ 

 
$GLOBALS['log']->fatal("fareed::");  


} 

} 

?>

======================================================

Error pop up in while open invoice and quote detail views
There was an error processing your request, please try again at a later time.