Results 1 to 6 of 6

Thread: How to set default values

  1. #1
    modified is offline Junior Member
    Join Date
    Sep 2006
    Posts
    3

    Default How to set default values

    Hi, I am trying to set default values for certain fields in the account module from variables in the url. Example:

    index.php?module=Accounts&action=EditView&return_m odule=Accounts&return_action=DetailView?pnumber=12 34567890&acctname=Test1

    This would open up a new account page with the phone office field reading 1234567890 and the account name being test 1

    i know i can use the $_get['pnumber'] and $_get['acctname'] variables to pull those values from the url. But when i set them to the variables $phone_office in the accounts.php file it tells me that there is an error:

    Parse error: parse error, unexpected T_VARIABLE in /var/www/html/crm/modules/Accounts/Account.php

    any help is greatly appreciated. Thanx!
    Last edited by modified; 2006-09-11 at 08:48 PM.

  2. #2
    rlbyrd is offline Sugar Community Member
    Join Date
    Jul 2006
    Posts
    40

    Default Re: How to set default values

    Can you post the modified code snippet?

  3. #3
    kbrill's Avatar
    kbrill is offline SugarCRM PS Engineer
    Join Date
    Jul 2004
    Location
    St Louis, MO
    Posts
    3,183

    Default Re: How to set default values

    Quote Originally Posted by modified
    i know i can use the $_get['pnumber'] and $_get['acctname'] variables to pull those values from the url. But when i set them to the variables $phone_office in the accounts.php file it tells me that there is an error:
    There are probably a hundred better ways to do this but your way needs to be done in the EditView.php file not the Account.php file. Look for where the vars for phone number and such are filled in and thats where you want to place your code.
    Kenneth Brill - Help Forum Moderator

    I do not respond to 'Private Messages'. Please email me directly instead

    When asking for help, PLEASE give us your Server Information and Version Numbers as asked for on the 'Post New Message' screen as well as any JavaScript errors shown at the bottom of the browser window.
    Help us Help You

  4. #4
    modified is offline Junior Member
    Join Date
    Sep 2006
    Posts
    3

    Default Re: How to set default values

    // Account is used to store account information.
    class Account extends SugarBean {
    var $field_name_map = array();
    // Stored fields
    var $date_entered;
    ~
    var $phone_fax;
    var $phone_office=$_Get['pnumber'];
    var $rating;
    var $shipping_address_street;
    var $shipping_address_city;
    var $shipping_address_state;
    var $shipping_address_country;
    ~
    // These are for related fields
    var $opportunity_id;
    var $case_id;

    Theres a snippit of the code, it is the declaration of variables in account.php I omitted some of the lines to shorten it. It refuses to take the get variable however if i say var $phone_office="1234567890"; The accounts page will come prefilled with thta number in the office phone number field

    As for the editview.php, I tried modfy the code their but it did not show up in the browser. Any suggestions of which lines i need to change?

    Thanx!!!

  5. #5
    stevec is offline Sugar Community Member
    Join Date
    Oct 2005
    Location
    London
    Posts
    1,100

    Default Re: How to set default values

    If you have editied the html to pass the variable in the URL thten you can do the following:
    Edit EditView.php and find the bit like:

    Code:
    if(isset($_REQUEST['parent_id'])) $xtpl->assign("PARENT_ID", $_REQUEST['parent_id']);
    if(isset($_REQUEST['parent_name'])) $xtpl->assign("PARENT_NAME", urldecode($_REQUEST['parent_name']));
    if(isset($_REQUEST['billing_address_street'])) $xtpl->assign("BILLING_ADDRESS_STREET", urldecode($_REQUEST['billing_address_street']));
    if(isset($_REQUEST['billing_address_city'])) $xtpl->assign("BILLING_ADDRESS_CITY", urldecode($_REQUEST['billing_address_city']));
    if(isset($_REQUEST['billing_address_state'])) $xtpl->assign("BILLING_ADDRESS_STATE", urldecode($_REQUEST['billing_address_state']));
    if(isset($_REQUEST['billing_address_postalcode'])) $xtpl->assign("BILLING_ADDRESS_POSTALCODE", urldecode($_REQUEST['billing_address_postalcode']));
    if(isset($_REQUEST['billing_address_country'])) $xtpl->assign("BILLING_ADDRESS_COUNTRY", urldecode($_REQUEST['billing_address_country']));
    if(isset($_REQUEST['ownership'])) $xtpl->assign("OWNERSHIP", urldecode($_REQUEST['ownership']));
    if(isset($_REQUEST['website'])) $xtpl->assign("WEBSITE", urldecode($_REQUEST['website']));
    
    $xtpl->parse("main");

    Just before the final $xtpl->parse("main");, add a like like

    Code:
    if(isset($_REQUEST['pnumber'])) $xtpl->assign("PHONE_OFFICE", urldecode($_REQUEST['pnumber']));
    I've not tested this so watch out for typos or errors.

  6. #6
    modified is offline Junior Member
    Join Date
    Sep 2006
    Posts
    3

    Default Re: How to set default values

    Thanx! Worked perfectly!

Thread Information

Users Browsing this Thread

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

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
  •