(@prmarketing if you click the “pencil” icon on your post above, you can see my edit and learn how to enter php
code with syntax highlighting)
After entering the edit, click the Raw button to see how it is done)
(@prmarketing if you click the “pencil” icon on your post above, you can see my edit and learn how to enter php
code with syntax highlighting)
After entering the edit, click the Raw button to see how it is done)
You code copy data from field “myfield_c” to field “date_start” of module Lead. You don’t do request to module Meeting. My code for you:
<?php
...
function copy(&$bean, $event, $arguments) {
$meeting_bean = new Meeting();
$meeting_bean->retrieve($bean-><field id of relationship with Meeting>);
$bean->date_start = $meeting_bean->date_start;
}
sorry,
so I have to create hooks
<?php
// Do not store anything in this file that is not part of the array or the hook version. This file will
// be automatically rebuilt in the future.
$hook_version = 1;
$hook_array = Array();
// position, file, function
$hook_array[‘after_save’] = Array();
$hook_array[‘after_save’][] = Array(1, ‘Value from one field to another’, ‘custom/modules/leads/my.php’, ‘User_hook’,‘copy’);
?>
and my.php
<?php
…
function copy(&$bean, $event, $arguments) {
$meeting_bean = new Meeting();
$meeting_bean->retrieve($bean->);
$bean->date_start = $meeting_bean->date_start;
}
Blockquote
$bean->date_start = $meeting_bean->date_start;
or
$bean->my_field = $meeting_bean->date_start;
I wrote about hook after_save if you make:
If you want:
What is your option?
Clean crm suite installation
latest SuiteCRM-7.11.10 version
START !!
in ftp duplicate field date_start
FTP
custom / module / Leads
I create the logic_hooks.php file
<?php
// Do not store anything in this file that is not part of the array or the hook version. This file will
// be automatically rebuilt in the future.
$hook_version = 1;
$hook_array = Array();
// position, file, function
$hook_array[‘after_save’] = Array();
$hook_array[‘after_save’][] = Array(1, ‘Value from one field to another’, ‘custom/modules/Leads/Leads_Hooks.php’, ‘Leads_Hooks’,‘copyField’);
?>
Blockquote
custom/module/Leads
creo il file Leads_Hooks.php
function copy(&$bean, $event, $arguments) {
$meeting_bean = new Meeting();
$meeting_bean->retrieve($bean->);
$bean->date_start= $meeting_bean->date_start;
}
Blockquote
If you want to write to field “date_start” of Lead object from field “date_start” of Meeting object, you sholud control changing in Meeting module using hook after_save.
Here is the code:
custom/modules/logic_hooks.php
$hook_version = 1;
$hook_array = Array();
$hook_array['after_save'] = Array();
$hook_array['after_save'][] = Array(1, '', 'custom/modules/Meetings/my.php', 'User_hook','copy');
custom/modules/Meetings/my.php
class User_hook {
function copy(&$bean, $event, $arguments) {
$lead_bean = new Lead();
$lead_bean->retrieve($bean-><field id of relationship with Lead>);
$lead_bean->date_start = $bean->date_start;
}
}
Change “field id of relationship with Lead” to correct field name. I see name “leads_meetings_1leads_ida” in this conversation.
Thanks, you really have a lot of patience!
Does not work !
I try to explain myself with images, let’s see if I can help you
Thank you so much
using your codes, when I create a lead, it gives me a blank page
… wait…i no have Change “field id of relationship with Lead” to correct field name. I see name “leads_meetings_1leads_ida” in this conversation.
There are some problems. Step by step.
Please @prmarketing , clear which type of relationship you want to use one-to-one or parent_name.
I had deleted everything, now I have created a new one to one relationship
Is it right to get my result?
I changed the code as follows, but when I create a lead I get a blank page
class User_hook {
function copy(&$bean, $event, $arguments) {
$lead_bean = new Lead();
$lead_bean->retrieve($bean-><meetings_leads_1meetings_ida>);
$lead_bean->date_start = $bean->date_start;
$lead_bean->save();
}
} Blockquote
Correct line:
$lead_bean->retrieve($bean->meetings_leads_1meetings_ida);
without: <>
And see comment before.
Please @prmarketing , clear which type of relationship you want to use one-to-one or parent_name.
I don’t understand what you mean, what should I do
i have modify $lead_bean->retrieve($bean->meetings_leads_1meetings_ida);
the lead is blank now
I use studio is simple for me, i have creare date_start field lead whit php
@prmarketing It’s good the comment. Because.
I made code and tested it for you.
Please, step by step:
class User_hook {
function copy(&$bean, $event, $arguments) {
if ($bean->parent_type=='Leads'){
$lead_bean = new Lead();
$lead_bean->retrieve($bean->parent_id);
$lead_bean->date_start_c = $bean->date_start;
$lead_bean->save();
}
}
}
you are great
I have no words to define you !!!
Thanks thanks thanks
if it is not difficult, I can ask you one last thing, since you are so kind and prepared
How can I make LBL_DATE_START
event today: red color
expired event: color …
future event: color
OK. I know decision. I write some late and I be ready for you answer tomorrow.
Decision for you @prmarketing :
$dictionary['Lead']['fields']['date_start_c']['function']=array('name' => 'dateStart', 'returns' => 'html', 'onListView' => 'true', 'include' => 'custom/modules/Leads/custom_field_html.php');
<?php
function dateStart($focus, $field, $value, $view){
$late="#0E44CC";
$early="#5E9902";
$today="#FF3609";
if($view==="ListView"){
global $timedate;
$delta = $timedate->fromUser($value)->format("Ymd") - $timedate->getNow()->format("Ymd");
if ($delta > 0){
$color=$early;
}else{
if ($delta < 0){
$color=$late;
} else{
$color=$today;
}
}
return "<b style='color:".$color."'>".$value."<b>";
}
}
Please remember if you change the field ‘date_start’ of Lead in Studio you lost addition line (point 2). You can add the line again but don’t fogett to make “Quick Repair and Rebuild”.