Results 1 to 7 of 7

Thread: Prepopulate fields. on create ... in edit view of module

  1. #1
    Linnane is offline Sugar Community Member
    Join Date
    Jun 2009
    Posts
    64

    Default Prepopulate fields. on create ... in edit view of module

    Hi,
    Trying to pre-populate fields in module.
    using sugarcrm ce 6.3

    Have tried to use sugar functionality (hooks).

    following this tutorial (Example for Opportunities) SugarCRM: Setting default for Cases and Opportunities - Documentation and Knowledgebase :: Omni Technology Solutions

    I have the 'before_save' hook working. But want the fields populated in on load ... thus allow the user to modify.

    I've tried the after_ui_frame but no joy ... removed the "&$bean," form the function Execute. The function executes but my fields aren't populated?


    My BIG plan is to create a custom button on one module which will open a Create record for another module the default values are in the URL ...

    Am I going the right way about it ... hooks and URL parameters?

    Can any one help or point me to a tutorial with sample code? Please....

    Regards
    Alan.

  2. #2
    SagarCRM's Avatar
    SagarCRM is offline Sugar Community Member
    Join Date
    Oct 2011
    Location
    Mumbai, Maharashtra, India
    Posts
    111

    Default Re: Prepopulate fields. on create ... in edit view of module

    Hi Alan,
    i think you are going good, my ways are quiet simple and cheap...dont know whether iit is actually you want..
    as you said on custom button click you are sending values through query string...why dont you set those values in bean in view.edit.php
    like
    if you are sending parameter say STATUS from query string you can set that like
    PHP Code:
    $this->bean->status $_REQUEST['status']; 
    we can do it in many ways if you don't want user to change this fields
    --

    Thanks & Regards,

    Sagar Salunkhe
    Mumbai, Maharashtra, INDIA

    sagar.salunkhe1991@gmail.com

    ~~ IT professionals never dies, they just go Offline... ~~


    sugar development and support services:- indian.sugarbean@gmail.com

  3. #3
    lijith's Avatar
    lijith is offline Sugar Community Member
    Join Date
    Jun 2009
    Location
    India
    Posts
    67

    Default Re: Prepopulate fields. on create ... in edit view of module

    To add button to the detail view of a module you have to create a view.detail.php file at custom/modules/{MODULE}/views/ folder.

    For more details check the link SugarCRM: Create button on the detail view « Php Bugs
    Lijith M Gopinath
    email : phpbugs@live.com
    website : PHP-Bugs

  4. #4
    Linnane is offline Sugar Community Member
    Join Date
    Jun 2009
    Posts
    64

    Default Re: Prepopulate fields. on create ... in edit view of module

    Hi
    Thanks or the replys -- the other side of my problem is after
    I have set these variables, how do I get the value
    into the textfield in the create screen of the next module?

    Regards
    Alan

  5. #5
    SagarCRM's Avatar
    SagarCRM is offline Sugar Community Member
    Join Date
    Oct 2011
    Location
    Mumbai, Maharashtra, India
    Posts
    111

    Default Re: Prepopulate fields. on create ... in edit view of module

    Quote Originally Posted by Linnane View Post
    Hi
    Thanks or the replys -- the other side of my problem is after
    I have set these variables, how do I get the value
    into the textfield in the create screen of the next module?

    Regards
    Alan

    As i said buddy...is the easiest way to achieve
    --

    Thanks & Regards,

    Sagar Salunkhe
    Mumbai, Maharashtra, INDIA

    sagar.salunkhe1991@gmail.com

    ~~ IT professionals never dies, they just go Offline... ~~


    sugar development and support services:- indian.sugarbean@gmail.com

  6. #6
    Linnane is offline Sugar Community Member
    Join Date
    Jun 2009
    Posts
    64

    Default Re: Prepopulate fields. on create ... in edit view of module

    In that view.edit.php ... I've only modified the getModuleTitle function.

    where do I add the line ... $this->bean->status = $_REQUEST['status']; ?

    Did I see something about a display function?
    can you give me a sample ? Sorry about this but I think I need a step by step. ?

    Also if I go down this road I assume I don't need the hooks (e.g. 'before_save' or 'after_ui_frame')?

    Thanks again
    Alan

  7. #7
    SagarCRM's Avatar
    SagarCRM is offline Sugar Community Member
    Join Date
    Oct 2011
    Location
    Mumbai, Maharashtra, India
    Posts
    111

    Default Re: Prepopulate fields. on create ... in edit view of module

    Quote Originally Posted by Linnane View Post
    In that view.edit.php ... I've only modified the getModuleTitle function.

    where do I add the line ... $this->bean->status = $_REQUEST['status']; ?

    Did I see something about a display function?
    can you give me a sample ? Sorry about this but I think I need a step by step. ?

    Also if I go down this road I assume I don't need the hooks (e.g. 'before_save' or 'after_ui_frame')?

    Thanks again
    Alan
    Hi Alan,
    your view.edit.php will contain something like this

    PHP Code:
    <?php
    if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

    require_once(
    'include/MVC/View/views/view.edit.php');


    class 
    CustomViewEdit extends ViewEdit{

        var 
    $ev;
         var 
    $type ='edit';
         var 
    $useForSubpanel false;  //boolean variable to determine whether view can be used for subpanel creates
         
    var $useModuleQuickCreateTemplate false//boolean variable to determine whether or not SubpanelQuickCreate has a separate display function
         
    var $showTitle true;

        
         function 
    CustomViewEdit()
        {
        
    $this->useForSubpanel TRUE;
        }
        
        function 
    ViewEdit(){
             
    parent::SugarView();
         }
        
        function 
    display(){
            
    $this->ev->process();
            if(
    $this->ev->isDuplicate) {
               foreach(
    $this->ev->fieldDefs as $name=>$defs) {
                       if(!empty(
    $defs['auto_increment'])) {
                          
    $this->ev->fieldDefs[$name]['value'] = '';
                       }
               }
            }

            
            
    /*focus on this line*/
            
    $this->bean->status $_REQUEST{'status'};
            
    /*focus on this line*/
            
            
            
    echo $this->ev->display($this->showTitle);

         }
    }
    ?>
    try it on your end..it should work properly fine..
    --

    Thanks & Regards,

    Sagar Salunkhe
    Mumbai, Maharashtra, INDIA

    sagar.salunkhe1991@gmail.com

    ~~ IT professionals never dies, they just go Offline... ~~


    sugar development and support services:- indian.sugarbean@gmail.com

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. How to view Custum Fields in detail vew and edit view
    By AnujAngural in forum Developer Help
    Replies: 4
    Last Post: 2010-09-09, 05:56 AM
  2. Missing custom fields in create / edit view
    By webchuck in forum Installation and Upgrade Help
    Replies: 4
    Last Post: 2010-05-11, 10:18 PM
  3. Can't Select fields from the Edit view
    By callumd in forum Help
    Replies: 2
    Last Post: 2010-03-16, 04:40 AM
  4. Replies: 13
    Last Post: 2007-10-04, 05:53 AM
  5. Replies: 5
    Last Post: 2007-05-21, 12:59 PM

Tags for this Thread

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
  •