Results 1 to 8 of 8

Thread: Ability to replicate opportunities?

  1. #1
    msuser is offline Member
    Join Date
    Jun 2011
    Posts
    7

    Default Ability to replicate opportunities?

    Hi,

    Is there either a featurein SugarCRM currently, or an add-on that would accomplish the following.

    replicate Opportunities into the future to assist in revenue planning and sales lifetime value reporting. This should operate similar to Outlook recurring events where an Opportunity can be assigned as a recurrence, with start and end dates as well as frequency. The ability to adjust these settings on an opportunity at a later date must also be available.

    Thanks for your help.

  2. #2
    blak3r's Avatar
    blak3r is offline Sugar Community Member
    Join Date
    Sep 2010
    Location
    Maryland
    Posts
    240

    Default Re: Ability to replicate opportunities?

    I haven't seen something like that... it's a neat idea i suppose.

    Here's how i'd implement it...

    Add a new custom field. It'd indicate if it's a Master or "Slave" opportunity. The default would be master.
    Then, you'd add an on save logic hook that created a bunch of opportunities based on another custom field you'd specify which indicated the frequency.

    If you needed the ability to later update the frequency you'd have to make your logic hook be able to delete existing slave opportunities.

    Once you have all the opportunities created, you could use the built in forecasting module for reporting.
    Sugar 6 Pro, On-Site (Apache 2.0, MySQL 5.1, PHP 5.2.6)

    My SugarForge Projects:
    Email To Sugar - Archive emails in any mail client by adding a BCC line.
    Task Dashlets Plus- Adds custom dashlets for: tasks assigned to me by others, delegated tasks, overdue tasks, and open tasks past start date

    www.blakerobertson.com

  3. #3
    msuser is offline Member
    Join Date
    Jun 2011
    Posts
    7

    Default Re: Ability to replicate opportunities?

    Thanks for the reply, so by the sounds of it there wouldn't be too much work involved. i was worried i'd have to "get under the hood" of sugarcrm and modify the system directly, but from what you're saying it can be accomplished via some custom fields and some code hooks.

    I must admit i've very new to SugarCRM, knowing it only at a very high level however I am a PHP developer so hopefully i'll be able to feel my way around.

    EDIT: is anyone able to get me started on where to look to get this working? got a few tutorials about hooks and stuff open however wanted to know if there's anything i'd be missing.
    Last edited by msuser; 2011-06-08 at 03:41 AM.

  4. #4
    msuser is offline Member
    Join Date
    Jun 2011
    Posts
    7

    Default Re: Ability to replicate opportunities?

    how do you programmatically add an opportunity? i need to take what the user has already entered in the form and create several other opportunities out of it by creating a custom hook on the onsave event.

  5. #5
    webcrmtechnologies is offline Sugar Community Member
    Join Date
    May 2011
    Location
    India
    Posts
    18

    Default Re: Ability to replicate opportunities?

    You can get all values from submitted Opportunity form using $bean object or $_REQUEST array.

    After manipulating opportunity dates and other values based on frequency you can create another record using after_save logic hook and method $bean->save();. But remember to create and set new $bean->id before save.

    Hope this can help you in your way...

  6. #6
    msuser is offline Member
    Join Date
    Jun 2011
    Posts
    7

    Default Re: Ability to replicate opportunities?

    Thanks,

    I actually thought it might be $bean->save() but wasn't quite sure.

    I managed to create a logic hook for after_save that would call a function, create a new bean and copy the required fields from the existing bean and save it.

    it works, but for some reason it saves about 250 of them and then crashes the page :S

    EDIT: i just realised that the reason it's creating so many is because for each new bean i create with the save() it will then come back to the after_save event again - lol. how would one check this to make sure it's only happening once?

    EDIT2: figured it out. I used the master/slave checkbox to determine if the bean should be copied. it works brilliantly.

    i can now define how i want to duplicate these opportunities, daily, weekly, monthly, 5 times 6 times 600 times. the next step is to be able to edit the master opportunitiy and to have any changes made propogate to the children by deleting the children and recreating them. whilst recreating them is fine, how do you delete specific opportunities in sugarcrm?

    EDIT3:

    after some digging i thought i'd be able to do this:
    PHP Code:
    $newOpp = new Opportunity();
    $newOpp->retrieve($_REQUEST['record']);
    $childOpps $newOpp->get_linked_beans('name','Opportunity'); 
    $newOpp does appear to have the current bean, and my understanding of get_linked_beans is that i'm saying give me all the beans that share the name with this bean and return them as an iteratable array of type Opportunity - am i wrong?

    It crashes on the line where i call get_linked_beans with the error "fatal call to getbeans() on a non-object".
    Last edited by msuser; 2011-06-29 at 05:53 AM.

  7. #7
    msuser is offline Member
    Join Date
    Jun 2011
    Posts
    7

    Default Re: Ability to replicate opportunities?

    I've seen people use this, however it just doesn't work for me.

    PHP Code:

    $childOpps 
    $bean->get_linked_beans('opportunities','Opportunity');  

    foreach(
    $childOpps as $opp)
    {} 
    it has the same error as the previous one. i can't seem to figure this out. i thought i may be able to get the account associated with this bean and then iterate over the opportunities on there, but it didn't work either.

    EDIT:

    Found out that the reason there is an error is because opportunities is not a link name for opportunity. however since it *is* for an account, i did the following and it works beautifully. now i can delete and recreate opportunities for my forecasting, woot!:

    PHP Code:
    $account = new Account();
    $account $account->retrieve($bean->account_id);

    $oops $account->get_linked_beans('opportunities','Opportunity');

    foreach (
    $opps as $opp)
    {
    if (
    $opp->name == $bean->name)
       
    $opp->mark_deleted($opp->id);

    Last edited by msuser; 2011-06-30 at 05:36 AM.

  8. #8
    webcrmtechnologies is offline Sugar Community Member
    Join Date
    May 2011
    Location
    India
    Posts
    18

    Default Re: Ability to replicate opportunities?

    good to hear you finally achieved your goals

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Replicate Contact Role function from opportunity
    By JVWay in forum Developer Help
    Replies: 0
    Last Post: 2009-08-19, 10:20 PM
  2. Telesales Script ability
    By kvillan in forum Feature Requests
    Replies: 7
    Last Post: 2009-03-11, 06:21 AM
  3. How to replicate this meeting popup in a custom module
    By andy60 in forum Developer Help
    Replies: 0
    Last Post: 2007-09-05, 07:09 AM
  4. Ability to Link documents
    By synaq in forum Feature Requests
    Replies: 4
    Last Post: 2005-08-01, 07:28 PM
  5. Ability to assign owner
    By denej in forum Feature Requests
    Replies: 1
    Last Post: 2004-07-06, 11:13 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
  •