Hey all! I've made a couple custom modules and I would really like to have them relate to the Accounts module. Any clue what files I need to edit to create a working relation between the Accounts module and my custom module?
Hey all! I've made a couple custom modules and I would really like to have them relate to the Accounts module. Any clue what files I need to edit to create a working relation between the Accounts module and my custom module?
Update your module bean to have it as a related field. Then you'll need to adjust your vardefs.php to make the relationship.Originally Posted by Danielg42
Look at Contacts, there is a relationship to accounts.
you'll probably need an accounts_modulename table as well.
id,account_id,module_id)
Thanks for the tips.
I have created the relation, but how do I get the "select account" field to appear in my module? It's not an option in studio.
Yeah, you'll need to make a custom call_back function.Originally Posted by Danielg42
Look at the EditView.html & EditView.php files to see how they do it.
I'm still a bit confused here...
I can't find any mention of a call_back function in the editview.php/.html files. Any help would be appreciated.
I'm in the same boat--any guidance would be greatly appreciated. I have managed to get a field that acts like "Account Name" in my custom module, but when I click on "Select" it does not pull up the Account Names module. Strangely enough, when I do a Mass Update from ListView, it works perfectly.
I used ModuleBuilder to create the custom module and the initial relationship, although getting the button on there took a great deal of PHP editing. (getting the "Account Name" field, I mean.)
I have the account name field and the pop up working and can select the account to associate with, but when I click save, it refuses to save the account id in my relationship field.
Here's the php I put in my modules editview.php to get the field. Maybe someone can tell me what line I need to have it save properly.
PHP Code:$popup_request_data = array(
'call_back_function' => 'set_return',
'form_name' => 'EditView',
'field_to_name_array' => array(
'id' => 'account_id',
'name' => 'account_name',
),
);
$json = getJSONobj();
$encoded_popup_request_data = $json->encode($popup_request_data);
$xtpl->assign('encoded_popup_request_data', $encoded_popup_request_data);
$xtpl->parse("main");
$xtpl->out("main");
require_once('include/javascript/javascript.php');
$javascript = new javascript();
$javascript->setFormName('EditView');
$javascript->setSugarBean($focus);
$javascript->addAllFields('');
require_once('include/QuickSearchDefaults.php');
$qsd = new QuickSearchDefaults();
$sqs_objects = array('account_name' => $qsd->getQSParent(),
'assigned_user_name' => $qsd->getQSUser(),
'campaign_name' => $qsd->getQSCampaigns(),
);
$sqs_objects['account_name']['populate_list'] = array('account_name', 'account_id');
$quicksearch_js = $qsd->getQSScripts();
$quicksearch_js .= '<script type="text/javascript" language="javascript">sqs_objects = ' . $json->encode($sqs_objects) . '</script>';
$xtpl->assign("JAVASCRIPT", get_set_focus_js() . $quicksearch_js);
$xtpl->assign("ID", $focus->id);
$seps = get_number_seperators();
$xtpl->assign("NUM_GRP_SEP", $seps[0]);
$xtpl->assign("DEC_SEP", $seps[1]);
$xtpl->assign("ACCOUNT_NAME", $focus->account_name);
$xtpl->assign("ACCOUNT_ID", $focus->account_id);
require_once('include/QuickSearchDefaults.php');
$qsd = new QuickSearchDefaults();
$sqs_objects = array('account_name' => $qsd->getQSParent(),
'assigned_user_name' => $qsd->getQSUser(),
'campaign_name' => $qsd->getQSCampaigns(),
);
$sqs_objects['account_name']['populate_list'] = array('account_name', 'account_id');
$quicksearch_js = $qsd->getQSScripts();
$quicksearch_js .= '<script type="text/javascript" language="javascript">sqs_objects = ' . $json->encode($sqs_objects) . '</script>';
Last edited by Danielg42; 2007-06-21 at 03:32 PM.
If I understand you properly, you're selecting the account name from the "select" box and it populates the field, but once you click save, the changes don't stick, right? If that's true, do the following:
1.) Check and make sure account_id and account_name are in the field_arrays.php file for whatever module you're trying to add this button to.
2.) Remove any instances of "account_id" or "account_name" = hidden at the top of your EditView.html file.
3.) Have you added a custom query to your bean file yet? If not, and you have mySQL, I can help you out--just let me know.
That's my exact issue. I have done everything on your list, except number 3...
Please tell me what query I need to add.![]()
Ah ha!
Never mind.
I needed to add account_id and account_name under the column fields, not under the list fields. Thank you very much.
The relation now works.
Spoke to soon.
I got one to work, but now it won't relate anymore.![]()
Last edited by Danielg42; 2007-06-21 at 05:42 PM.
There are currently 1 users browsing this thread. (0 members and 1 guests)
Bookmarks