Page 1 of 2 12 LastLast
Results 1 to 10 of 12

Thread: Account Relation

  1. #1
    Danielg42 is offline Sugar Community Member
    Join Date
    Jun 2006
    Location
    Orange County, CA
    Posts
    187

    Default Account Relation

    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?

  2. #2
    sacramentojoe is offline Sugar Community Member
    Join Date
    Nov 2005
    Posts
    447

    Default Re: Account Relation

    Quote Originally Posted by Danielg42
    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.

    Look at Contacts, there is a relationship to accounts.

    you'll probably need an accounts_modulename table as well.
    id,account_id,module_id)

  3. #3
    Danielg42 is offline Sugar Community Member
    Join Date
    Jun 2006
    Location
    Orange County, CA
    Posts
    187

    Default Re: Account Relation

    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.

  4. #4
    sacramentojoe is offline Sugar Community Member
    Join Date
    Nov 2005
    Posts
    447

    Default Re: Account Relation

    Quote Originally Posted by Danielg42
    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.

    Look at the EditView.html & EditView.php files to see how they do it.

  5. #5
    Danielg42 is offline Sugar Community Member
    Join Date
    Jun 2006
    Location
    Orange County, CA
    Posts
    187

    Default Re: Account Relation

    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.

  6. #6
    spectheintro is offline Sugar Community Member
    Join Date
    May 2006
    Posts
    59

    Default Re: Account Relation

    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.)

  7. #7
    Danielg42 is offline Sugar Community Member
    Join Date
    Jun 2006
    Location
    Orange County, CA
    Posts
    187

    Default Re: Account Relation

    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.

  8. #8
    spectheintro is offline Sugar Community Member
    Join Date
    May 2006
    Posts
    59

    Default Re: Account Relation

    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.

  9. #9
    Danielg42 is offline Sugar Community Member
    Join Date
    Jun 2006
    Location
    Orange County, CA
    Posts
    187

    Default Re: Account Relation

    That's my exact issue. I have done everything on your list, except number 3...
    Please tell me what query I need to add.

  10. #10
    Danielg42 is offline Sugar Community Member
    Join Date
    Jun 2006
    Location
    Orange County, CA
    Posts
    187

    Default Re: Account Relation

    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.

Page 1 of 2 12 LastLast

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 2006-08-28, 01:27 PM
  2. Showing Member Organizations of Account
    By Lennu in forum General Discussion
    Replies: 0
    Last Post: 2006-03-27, 12:31 PM
  3. Import contact on existing account
    By esolarc in forum Developer Help
    Replies: 1
    Last Post: 2006-03-22, 01:21 PM
  4. Automatically Link Lead to Account
    By cmarcus in forum Feature Requests
    Replies: 2
    Last Post: 2006-03-20, 02:44 PM
  5. Contacts not showing under Account
    By adavidson in forum Help
    Replies: 0
    Last Post: 2005-06-04, 08:39 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •