Results 1 to 2 of 2

Thread: Workflow and copy fields

  1. #1
    REByers is offline Sugar Community Member
    Join Date
    Oct 2007
    Location
    North West England
    Posts
    182

    Default Workflow and copy fields

    I want to populate the contents of a field from another field when a certain point is reached in the sales cycle.

    I have the amount field, a new amount outstanding field, and the status field in Oppotunities.

    When the status field gets set to Won, I want the contents of the amount field copied into the new amount outstanding field.

    Is this possible in the workflow? I am using 5.0.0f Enterprise.

  2. #2
    chad.hutchins is offline Sugar Community Member
    Join Date
    May 2007
    Location
    Texas
    Posts
    141

    Default Re: Workflow and copy fields

    Yes, you can do this.

    This is where I learned: http://www.sugarcrm.com/wiki/index.p...l_custom_logic

    But for you specifically, in your custom/modules/Opportunities folder, you will need to add this to your logic_hooks.php file:
    PHP Code:
    $hook_array['before_save'][] = Array(2'actionName''custom/modules/Opportunities/Opportunities_cstm.php','Opportunities_cstm','checkOpportunityStatus'); 
    (The above should be on a single line, and for some reason there is an odd space between the 'c' and 'k' in 'checkOpportunityStatus'.)

    The above code tells Sugar to execute the checkOpportunityStatus function in the Opportunities_cstm object located in the custom/modules/Opportunities/Opportunities_cstm.php file just before an Opportunity record is saved to the database.

    Now you will need to create the Opportunities_cstm.php file and place it in your custom/modules/Opportunities directory. This is what should be in the file:

    PHP Code:
    define('sugarEntry',TRUE);
    if(!
    defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');

    class 
    Opportunities_cstm {
        function 
    checkOpportunityStatus(&$bean$event$arguments) {
            if (
    $_REQUEST['status']=='Won') {
                
    $bean->new_amount_standing $_REQUEST['amount'];
            }
        }

    I havne't tested this code, but it should be a start. Please post back with any questions.

    Other Sugar developers, please let me know if this is not the proper way to do this. Thanks.
    Last edited by chad.hutchins; 2008-08-11 at 05:38 PM. Reason: code fix

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. Module development workflow and source code management
    By SanderMarechal in forum Developer Help
    Replies: 2
    Last Post: 2008-07-29, 02:10 PM
  2. Workflow enhancements
    By cbierwerth in forum Feature Requests
    Replies: 3
    Last Post: 2008-05-14, 04:18 PM
  3. Simple linear workflow
    By lurkerfilms in forum Feature Requests
    Replies: 0
    Last Post: 2007-12-22, 06:26 PM
  4. What is Workflow management?
    By ramji123 in forum Customer Support
    Replies: 2
    Last Post: 2007-01-18, 05:18 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
  •