I have created a Custom Module called Assets. In this module it ties the ownership of a product to a customer.
It Captures
Account
Product
Serial Number.
I would lik eto create a 4th field that is not user editable and on save creates an entrey which is teh Concatenated result of Product & Serial number.
I am assuming i will need to use a Logic Hook - does anyone else have a better idea or a suggestion of how to structure the Logic Hook?
Hello,
Yes you need to use before_save logic hook, something like
$bean->field_name = $bean->fieldOne.“-".$bean->fieldTwo;
Take a look here for more info about logic hook
I have done as follows, but nothing is saving - any ideas?
Logic Hook - you may recognise one :-0
<?php
$hook_version = 1;
$hook_array = Array();
$hook_array['process_record'][] = Array(1, 'Check Dup','custom/modules/Ass3D_AssetManagement/checkDup.php','checkDupC', 'checkDupF');
$hook_array['before_save'][] = Array(1, 'createName','custom/modules/Ass3D_AssetManagement/createName.php','createNameC','createNameF');
?>
createName.php
<?php
class createNameC{
function createNameF($bean, $event, $arguments){
// Here set the name to the Account + Serial Number, taking into account that either of them may not be set.
$bean->name = trim(trim(trim($Account. ' / ' .$serial_number), '/'));
}
}
?>
Hello
Your logic hook name is missing in $hook_array array.
it should be something like $hook_array[’<LOGIC_HOOK_NAME>’]
I just cleaned my code up and it now works perfectly and looks like this, the point is to create a unique name for a record in a Custom Module - where the name consists of a Machine Serial Number and the Account Name.
createName.php
<?php
class createNameC{
function createNameF($bean, $event, $arguments){
// Here set the name to the Account + Serial Number,
$bean->name = trim(trim($bean->ass3d_assetmanagement_accounts_name. " - " .$bean->serial_number));
}
}
?>
logicHooks.php
<?php
$hook_version = 1;
$hook_array = Array();
$hook_array['process_record'] = Array();
$hook_array['process_record'][] = Array(1, 'Check Dup','custom/modules/Ass3D_AssetManagement/checkDup.php','checkDupC', 'checkDupF');
$hook_array['before_save'] = Array();
$hook_array['before_save'][] = Array(1, 'createName','custom/modules/Ass3D_AssetManagement/createName.php','createNameC','createNameF');
?>