Hi All,
How to know if a field is audited in a module,in its logic hook
Regards
Sidhu
Hi All,
How to know if a field is audited in a module,in its logic hook
Regards
Sidhu
Hi Sidhu,
If it is just about checking if audit is enabled simply go to Admin > Studio > Fields and check for the audit checkbox:
Best,
Dennis
i am aware about this,but i want to know how can we loop through the fields in a logic hook and retreive the fields which have audit as checked
Regards
sidhu
Ah ok now I see. Which version are your running?
In Sugar7 with Rest v10 you can use GET /metadata to receive all fields etc. In the following example I got the whole metadata for Accounts. In there you will find the fields and for each audited field you will see
[audited] => 1
$url = $base_url . "/oauth2/token";
$oauth2_token_arguments = array(
"grant_type" => "password",
//client id/secret you created in Admin > OAuth Keys
"client_id" => "test",
"client_secret" => "test",
"username" => $username,
"password" => $password,
"platform" => "base"
);
$oauth2_token_response = call($url, '', 'POST', $oauth2_token_arguments);
//Endpoint - GET /<metadata>/
$url = $base_url . "/metadata/";
$record_arguments = array(
"module_filter" => "Accounts",
);
$record_response = call($url, $oauth2_token_response->access_token, 'GET', $record_arguments);
Hi Sidhu,
Please try below code
class Class_logichook_custom {
function fn_before_save($bean, $event, $arguments)
{
if(!empty($bean->field_name_map))
{
foreach($bean->field_name_map as $field_nm_arr)
{
if($field_nm_arr['audited'])
{
echo $field_nm_arr['name']; echo '<br>';
}
}
exit;
}
}
}
Hi Sidhu,
Please try below code
class Class_logichook_custom {
function fn_before_save($bean, $event, $arguments)
{
if(!empty($bean->field_name_map))
{
foreach($bean->field_name_map as $field_nm_arr)
{
if($field_nm_arr['audited'])
{
echo $field_nm_arr['name']; echo '<br>';
}
}
exit;
}
}
}
class Class_logichook_custom {
function fn_before_save($bean, $event, $arguments)
$str='';
if(!empty($bean->field_name_map))
{
foreach($bean->field_name_map as $field_nm_arr)
{
if($field_nm_arr['audited'] == 1)
{
$str .= $field_nm_arr['name']; echo '<br>';
}
}
}
$bean->description = $str;
$bean->save();
}
}
worked perfect for me.
Regards
Sidhu