AnsweredAssumed Answered

Dependency code not working in onDemand instance but does in local

Question asked by Angel Martinez on Jan 26, 2018
Latest reply on Feb 8, 2018 by Angel Martinez

Hello, 

 

I'm facing an issue with the following dependency. It is located at ./custom/Extension/modules/Opportunities/custom_dep.php path.

 

The following code creates a Read Only dependency by field value and role.

The overall description is:

If the user has Sales Representative role, and the status_oppty_c field is In Progress, then it will lock the fields in the array, if it has any other Status, then it will lock the fields in the other array. 

 

Note: The code works fine in my local instance, which is an installed backup of the ondemand version.

 

Same version, same code, same roles, same fields, different result.

 

Does anybody have faced a similar issue? Sugar7.8.x

 

<?php

global $current_user;
$GLOBALS['log']->fatal("is_admin:" . $current_user->is_admin);

if(!isset($GLOBALS['unique_flag'])){
$GLOBALS['log']->fatal("inside");

if(!$current_user->is_admin){
$userRoleArray = ACLRole::getUserRoleNames($current_user->id);
$isSalesRep = in_array("Sales Representative", $userRoleArray);

//In Progress
$dependencies['Opportunities']['InProgress_RO'] = array(
'hooks' => array("edit"),
//Trigger formula for the dependency. Defaults to 'true'.
'trigger' => 'equal($status_oppty_c,"In Progress")',
'triggerFields' => array('status_oppty_c'),
'onload' => true,
//Actions is a list of actions to fire when the trigger is true
'actions' => array(),
//'notActions' => array(),
);
if($isSalesRep){
$InProgress_oppfields = array(
'description' => 'false',
'date_closed' => 'false',
'lead_source' => 'false',
'assigned_user_id' => 'false',
'assigned_user_name' => 'false',
'sales_stage' => 'false',
'team_name' => 'false',
'account_id' => 'true',
'account_name' => 'true',
'accounts' => 'true',
'amount' => 'true',
'base_rate' => 'true'
);
foreach ($InProgress_oppfields as $field1 => $value) {
$dependencies['Opportunities']['InProgress_RO']['actions'][] = array(
'name' => 'ReadOnly', //Action type
//The parameters passed in depend on the action type
'params' => array(
'target' => $field1,
'label' => $field1 . '_label', //normally <field>_label
'value' => $value, //Formula
),
);
}
}else{
$Lock_all_oppfields = array(
'account_id' => 'true',
'account_name' => 'true',
'accounts' => 'true',
'amount' => 'true',
'assigned_user_id' => 'true',
'assigned_user_link' => 'true',
'assigned_user_name' => 'true',
'base_rate' => 'true',
'construction_cost_c' => 'true',
'created_by' => 'true',
'created_by_link' => 'true',
'created_by_name' => 'true',
'currency_id' => 'true',
'date_closed' => 'true'
);

foreach ($Lock_all_oppfields as $field1 => $value) {
$dependencies['Opportunities']['InProgress_RO']['actions'][] = array(
'name' => 'ReadOnly', //Action type
//The parameters passed in depend on the action type
'params' => array(
'target' => $field1,
'label' => $field1 . '_label', //normally <field>_label
'value' => $value, //Formula
),
);
}
}
//ends admin condition
}
}
$GLOBALS['unique_flag'] = true;

 


?>

Outcomes