Results 1 to 5 of 5
Like Tree1Likes
  • 1 Post By ashdwi1

Thread: change field before_retrieve

  1. #1
    z3r0 is offline Sugar Community Member
    Join Date
    May 2009
    Posts
    189

    Question change field before_retrieve

    Hi,
    i want update a field in account module if an user click on an account. So i write a hook with the action before_retrieve. In the i get the ID from the account, which i want update, with the third argument (see code listing)

    PHP Code:
    class NiceHook {
    function 
    niceFunction(&$focus$event$arguments) {
        if(
    $_REQUEST['action'] == 'DetailView'
        {
            require_once(
    'modules/Accounts/Account.php');
            
    $tempAccount = new Account();
            
    $tempAccount->retrieve($arguments->id);
            ....
            
    $tempAccount->save();    
    }

    So i retrieve my account, because i have only the id and than i want update them. But with the retrieve function i start a never ending loop, beacause my hook is before_retrieve, too.
    What is the best practice to update an account before the user see them, without using SQL-statements?

  2. #2
    ashdwi1's Avatar
    ashdwi1 is offline Sugar Community Member
    Join Date
    May 2008
    Location
    Noida
    Posts
    198

    Default Re: change field before_retrieve

    hey,
    have you tried , same code on predisplay function on view.detail.php for account module???
    thanks
    z3r0 likes this.
    Almost available at skype or gtalk at ashdwi1.

    SugarForge Project:
    http://www.sugarforge.org/projects/gmapdirection
    Email: ashdwi1@gmail.com
    Mob: +919005468298

    Hire us at Odesk at
    https://www.odesk.com/users/~~b9eff8ff219fd705

    Hire Us at Elance at:
    http://ashdwi1.elance.com

  3. #3
    z3r0 is offline Sugar Community Member
    Join Date
    May 2009
    Posts
    189

    Default Re: change field before_retrieve

    thanks for response

    are you mean someting like this?

    PHP Code:
    class AccountsViewDetail extends ViewDetail {


         function 
    AccountsViewDetail(){
             
    parent::ViewDetail();
         }

            function 
    predisplay() {
    // code here -> ?
           
    }
         function 
    display(){
            ...
           } 
    or how exactly to use functions?

  4. #4
    ashdwi1's Avatar
    ashdwi1 is offline Sugar Community Member
    Join Date
    May 2008
    Location
    Noida
    Posts
    198

    Default Re: change field before_retrieve

    yes, at same place.
    Almost available at skype or gtalk at ashdwi1.

    SugarForge Project:
    http://www.sugarforge.org/projects/gmapdirection
    Email: ashdwi1@gmail.com
    Mob: +919005468298

    Hire us at Odesk at
    https://www.odesk.com/users/~~b9eff8ff219fd705

    Hire Us at Elance at:
    http://ashdwi1.elance.com

  5. #5
    rafael.q.g@hotmail.com's Avatar
    rafael.q.g@hotmail.com is offline Sugar Community Member
    Join Date
    Jun 2011
    Location
    Florianópolis - Brazil
    Posts
    782

    Default Re: change field before_retrieve

    There is also a logic hook named before_retrieve where you can change fields values before a record be displayed.
    Rafael Queiroz Gonçalves
    Advanced OMG UML Certified Professional
    Sun Certified Enterprise Architect for the Java Platform
    Sun Certified Programmer for the Java 2 Platform
    IBM Certified Advanced Application Developer - Lotus Notes and Domino
    IBM Certified Application Developer - IBM WebSphere Portlet Factory
    Computer Science Mastering / UFSC - PPGCC

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. before_retrieve and Opportunities
    By pixprotom in forum Developer Help
    Replies: 2
    Last Post: 2011-02-09, 02:25 AM
  2. loop by before_retrieve hook?
    By z3r0 in forum Developer Help
    Replies: 1
    Last Post: 2010-12-12, 06:16 PM
  3. Replies: 0
    Last Post: 2010-01-14, 02:56 PM
  4. Replies: 4
    Last Post: 2009-02-23, 12:45 PM
  5. Replies: 1
    Last Post: 2007-05-01, 05:34 PM

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
  •