I like to add a checkbox to contacts module, which value should be checked/unchecked based on a condition. The condition is if the contact extsts in the prospects list, then the check box should get checked.
How can this be done? Thanks in advance.
I like to add a checkbox to contacts module, which value should be checked/unchecked based on a condition. The condition is if the contact extsts in the prospects list, then the check box should get checked.
How can this be done? Thanks in advance.
I'm not a pro by any means, but it sounds like if you do what you want, you will have to go in and add custom PHP coding into some files (I don't know which one).
Why don't you just add a relate field. That way when you are entering in a new contact, you can start to type the name for the prospect and Sugar, using ajax, will populate the field if the name is in the propspects list. You will also have the ability to click SELECT and then search for the prospect.
I think it would be much easier, the other way probably isn't upgrade safe either.
________
Sharif
Last edited by jim.thornton; 2011-09-08 at 04:35 AM.
Thank you very much for the response jim.thornton.
I am fairly new to sugarCRM. Can you please detail a little bit & help me out?
Hi honeybee
Do you want to get this field displayed into both DetailView and EditView or only into one of these views?
For EditView:
You need to:
1. create a custom controller for Contacts module (custom/modules/Contacts/controller.php) and implement the function action_editview;
2. Create an extended vardefs for Contacts module (custom/Extension/modules/Contacts/Ext/Vardefs/vardefs,ext,php) to add the checkbox field definition into it. This field must have the attribute 'souce' set as 'non-db'. Remember to go into Admin -> Repair -> Rebuild Extension;
3. Create a sql query which identifies is this contact exist into some specific Prospect List. If yes set the checkbox as checked;
Done
André Lopes
DevToolKit / Project of the Month - June 2009
Lampada Global Services- Open Source Solutions
Avenida Ipiranga, 318
Bloco B - CJ 1602
São Paulo, SP 01046-010
Brazil
Office: +55 11 3237-3110
Mobile: +55 11 7636-5859
e-mail: andre@lampadaglobal.com
Lampada Global delivers offshore software development and support services to customers around the world.
Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.
I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.
Hi Andopes,
Thank you so much for the response.
I had problems with 'honeybee1', this account has been locked out. I created another account with 'honeybee2'.
Can you pleas ehelp me out by check thid code? Not sure am I in the right direction. Many thanks for yur help.
I added the following code:
I added a custom check box field to contacts module with name 'my_customfield_c'. Nt sure if this is required.
To custom/Extension/modules/Contacts/Ext/Vardefs/Vardefs.Ext.php
<?php
$dictionary["Contact"]["fields"]["my_customfield_c"] = array (
'name' => 'my_customfield_c',
'source' => 'non-db',
'vname' => 'LBL_MY_CUSTOMFIELD_C',
'save' => true,
'module' => 'ProspectLists',
);
?>
custom/modules/Contacts/controller.php
<?php
require_once('include/MVC/Controller/SugarController.php');
require_once('modules/Contacts/ContactsEditView.php');
class ContactsController extends SugarController {
function action_editview() {
$isRecExists =new ContactsEditView();
if ($isRecExists != null) $this->bean->my_customfield_c = 'Checked';
}
}
?>
Wrote a query to check the record in ContactsEditView() ;
custom/Extension/modules/Contacts/Ext/Vardefs/Vardefs.Ext.php
<?php
$dictionary["Contact"]["fields"]["my_customfield_c"] = array (
'name' => 'my_customfield_c',
'source' => 'non-db',
'vname' => 'LBL_MY_CUSTOMFIELD_C',
'type' => 'bool',
);?>
custom/modules/Contacts/controller.php
<?php
require_once('include/MVC/Controller/SugarController.php');
require_once('modules/Contacts/ContactsEditView.php');
class ContactsController extends SugarController {
function action_editview() {
$isRecExists =new ContactsEditView();
if ($isRecExists != null) $this->bean->my_customfield_c = 'Checked';
}
}?>
I believe this is the correct content.
Cheers
André Lopes
DevToolKit / Project of the Month - June 2009
Lampada Global Services- Open Source Solutions
Avenida Ipiranga, 318
Bloco B - CJ 1602
São Paulo, SP 01046-010
Brazil
Office: +55 11 3237-3110
Mobile: +55 11 7636-5859
e-mail: andre@lampadaglobal.com
Lampada Global delivers offshore software development and support services to customers around the world.
Lampada is proud to be a SugarCRM Gold Partner, revolutionizing Customer Relationship Management.
I DO NOT answer questions through PM and Email. If you need some help post your question into SugarForum.
Hi Andpes,
Thank you fr the rresponse. after I made the changes, and rebuild, the edit form is not coming up in the edit view.
for simplicity sake and for testing, I am using the following code for controller.php
I tried '1' instead of 'Checked', still the same problem. Adding the custm field with this is right thing? Filename and paths seems to be correct. No clue what might be the reason. Any ideas, please help me.
<?php
require_once('include/MVC/Controller/SugarController.php');
class ContactsController extends SugarController {
function action_editview() {
$this->bean->my_customfield_c = 'Checked';
}
}
?>
Nevermind. I forgot add
$this->view = 'edit';
Seems working fine. Thank you so much for your help.
Hi andopes,
One more quick question. How can we write custom code (like executing the query) while saving in the edit view? Is there a function like action_EditView?
Fr ex, If I want to save data in one of the table created by me.
Where can I find all these information?
Thank you for your patience.
Last edited by honeybee2; 2009-03-10 at 11:32 PM.
You could write the code into a logic hook. See the logic hook section in the developer docs.
SugarForge Projects:
JJWDesign Google Maps
JJWDesign Tools and Reports
Follow my blog postings at JJW Design.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks