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

Thread: Auto assign leads to one user

  1. #1
    moroccanjoe2 is offline Member
    Join Date
    Sep 2010
    Posts
    11

    Default Auto assign leads to one user

    Hey guys,

    I was wondering if anyone had an idea on how to auto assign newly created leads to a particular user (not the sugar admin). The way it works now is that it auto-fills the current logged-in user into the "assigned to" field. We are on sugar 6.0.1 if that makes any difference.

    Thank you for your help!
    Joe

  2. #2
    moroccanjoe2 is offline Member
    Join Date
    Sep 2010
    Posts
    11

    Default Re: Auto assign leads to one user

    Can anyone point me in the right direction please? Just tell me where to look, that would be greatly helpful! Thanks in advance!

  3. #3
    Angel's Avatar
    Angel is offline Sugar Community Member
    Join Date
    Jul 2005
    Location
    Los Angeles
    Posts
    4,813

    Default Re: Auto assign leads to one user

    You can easily do this via a logic hook. The logic hook code would essentially override the selected Assigned User with whatever value you want.

    Take a look at these examples on my blog for an idea, as well as the RoundRobin module (link in my sig):

    http://cheleguanaco.blogspot.com/search?q=logic+hook
    Regards,

    Angel Magaņa
    Co-Author: Implementing SugarCRM 5.x (Packt Publishing -- Sept. 2010)
    Blog: http://cheleguanaco.blogspot.com.
    Twitter: @cheleguanaco.

    ________
    | Projects: |_____________________________________
    |
    | CandyWrapper (.NET Wrapper for SugarCRM SOAP API). Source now available on GitHub!
    | GoldMine to SugarCRM Express Conversion. Latest: 1.0.1.7 (Nov. 3, 2009)
    | CRM SkyDialer (Skype Integration). Latest: 1.0.2 (Feb. 17, 2010)
    | Round Robin Leads Assignment
    | Phone Number Formatter
    | CaseTwit (Twitter Integration)
    ______________________________________________

  4. #4
    moroccanjoe2 is offline Member
    Join Date
    Sep 2010
    Posts
    11

    Default Re: Auto assign leads to one user

    Quote Originally Posted by Angel View Post
    You can easily do this via a logic hook. The logic hook code would essentially override the selected Assigned User with whatever value you want.

    Take a look at these examples on my blog for an idea, as well as the RoundRobin module (link in my sig):

    http://cheleguanaco.blogspot.com/search?q=logic+hook
    Angel,

    Thank you very much for the quick pointer. I did look at RoundRobin but unfortunately I am on 6.0.1 which is not supported (doesn't let me install even if I modify the manifest.php file to include 6.0). My issue is what I should assign to the Assigned_user_id. Do you assign the ID from the database or the name or something else?

    What I have right now in the php file that is called by the hook (inside the class and then the function) is:
    $bean->assigned_user_id = "686005cd-2122-b8dd-b58d-4c978647bcce"; That string is the user's id that I want to assign.


    Again thanks a lot for your help!

  5. #5
    Angel's Avatar
    Angel is offline Sugar Community Member
    Join Date
    Jul 2005
    Location
    Los Angeles
    Posts
    4,813

    Default Re: Auto assign leads to one user

    You don't need to install it, just unzip it and look at the code.

    Anyway, yes, that's the idea. Take the ID value from the database, from the Users table and assign it to $bean->assigned_user_id as you've indicated.
    Regards,

    Angel Magaņa
    Co-Author: Implementing SugarCRM 5.x (Packt Publishing -- Sept. 2010)
    Blog: http://cheleguanaco.blogspot.com.
    Twitter: @cheleguanaco.

    ________
    | Projects: |_____________________________________
    |
    | CandyWrapper (.NET Wrapper for SugarCRM SOAP API). Source now available on GitHub!
    | GoldMine to SugarCRM Express Conversion. Latest: 1.0.1.7 (Nov. 3, 2009)
    | CRM SkyDialer (Skype Integration). Latest: 1.0.2 (Feb. 17, 2010)
    | Round Robin Leads Assignment
    | Phone Number Formatter
    | CaseTwit (Twitter Integration)
    ______________________________________________

  6. #6
    moroccanjoe2 is offline Member
    Join Date
    Sep 2010
    Posts
    11

    Default Re: Auto assign leads to one user

    Quote Originally Posted by Angel View Post
    You don't need to install it, just unzip it and look at the code.

    Anyway, yes, that's the idea. Take the ID value from the database, from the Users table and assign it to $bean->assigned_user_id as you've indicated.
    Thanks again for your help! The code works but the only thing is that I need to execute the hook while loading page (I want the assigned user loaded by default in the "Assigned to" Box when creating a lead but It could be changed later). Do you know what type of hook will work best for this use? I tried after_retrieve, after_ui_frame, after_ui_footer, server_round_trip, and before_save but they don't do what I need them to do.

    Appreciate all your help!

  7. #7
    Angel's Avatar
    Angel is offline Sugar Community Member
    Join Date
    Jul 2005
    Location
    Los Angeles
    Posts
    4,813

    Default Re: Auto assign leads to one user

    That is a little bit different, although, I would personally prefer doing it via a before_save/after_save hook, but it depends on the scenario.

    The advantage of the before/after_save approach is that the user cannot override it by choosing a different value for the field. Again, your needs may dictate otherwise.
    Regards,

    Angel Magaņa
    Co-Author: Implementing SugarCRM 5.x (Packt Publishing -- Sept. 2010)
    Blog: http://cheleguanaco.blogspot.com.
    Twitter: @cheleguanaco.

    ________
    | Projects: |_____________________________________
    |
    | CandyWrapper (.NET Wrapper for SugarCRM SOAP API). Source now available on GitHub!
    | GoldMine to SugarCRM Express Conversion. Latest: 1.0.1.7 (Nov. 3, 2009)
    | CRM SkyDialer (Skype Integration). Latest: 1.0.2 (Feb. 17, 2010)
    | Round Robin Leads Assignment
    | Phone Number Formatter
    | CaseTwit (Twitter Integration)
    ______________________________________________

  8. #8
    angelababy is offline Banned
    Join Date
    Jul 2010
    Posts
    60

    Default Re: Auto assign leads to one user

    Thanks so much for the wonderful information you provided us

  9. #9
    jlabuelo is offline Sugar Community Member
    Join Date
    Apr 2008
    Posts
    426

    Default Re: Auto assign leads to one user

    Hi

    I am trying to avoid users to assign the records they create of a custom module to other users, so what I do is removiing the "Assigned to" field from the EditView. However this is a problem as if the field is not present, the record is not assigned to the creator, (as I do want the owner to appear in the DetailView and ListView).

    What I thought was creating a before_save hook to assign the id of the creator to the $bean->Assigned_user_id field of the new record... that is why I have tried to follow your examples... but dont know how to get the user_id of the creator of a record to complete this code... Also just would like this before_save to work at creation time, as if the record is already assigned dont want it to be assigned to every user that can modify the record.

    Could you please point me how I can conclude this code to get it working?

    Thanks a lot

    (This is the before_save hook)

    PHP Code:
    <?php

    /*************************************
    This class should assign the record to the user id of the creator
    in creation time
    *************************************/

    class Asignacion {

     function 
    AsignacionAutomatica(&$bean$event$arguments
     {
      
      if (!(
    $bean->assigned_usr_id == '') &&  !($bean->assigned_usr_id == null))
      
      {
          
    $bean->assigned_usr_id =
      }
      
      }

    }

    ?>

  10. #10
    davidboris is offline Sugar Community Member
    Join Date
    May 2010
    Posts
    1,113

    Default Re: Auto assign leads to one user

    Hello,

    Try this,

    PHP Code:
    if (!($bean->assigned_usr_id == '') &&  !($bean->assigned_usr_id == null)) 
       
      { 
          global 
    $current_user;
          
    $bean->assigned_usr_id $current_user->id;
      } 
    Thumbs up.

    Skype ID - david__boris

    SugarForge Projects:

    WYSIWYG now in studio!(Version 1.1 is out now!)

    Sugar Feeds on your personalized home pages like iGoogle, My Yahoo!, etc.

    Fab Tools! > Dashlet Not Followed Opportunities for past six Months

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: 2
    Last Post: 2009-08-16, 03:10 PM
  2. Auto Assign Lead/Contact to User Based on Zip
    By trega in forum Developer Help
    Replies: 1
    Last Post: 2009-06-11, 04:01 AM
  3. Assign imported leads to a user
    By khalidh in forum Help
    Replies: 0
    Last Post: 2007-05-18, 09:10 PM
  4. Import Leads and assign user
    By ceshine in forum General Discussion
    Replies: 7
    Last Post: 2006-11-30, 05:37 AM
  5. Leads Auto Assign to
    By ahirsh in forum Help
    Replies: 0
    Last Post: 2006-03-08, 10:25 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
  •