ACTION BUTTON - Possible to Insert Current User in an Action with formula build?

SELL 13.1

Creating an Action Button in Leads that will update 3 fields in a record. (The first 2 fields are working fine.)

The field we are having trouble setting up an Action is called "Re-engaged by" which is an existing relate field and when populating manually allows search and select of the active user list and is required when changing the lead status to "Re-Engaged".  We would like the "Re-engaged by" field  to populate like the  Modified By and Created By system fields do with the Current User Name when this Action Button is clicked.

As I have tried many things and am struggling to accomplish this, you all are my last resort to help save users time.

Hopefully I have explained this well enough to ask if this is even possible to enter as an Action, and if so, how do we accomplish this?  

  • Hi  

    Perhaps this custom sugarLogic function can help you.

    Save it into custom/include/Expressions/Expression/String/currentUserExpression.php

    Run "Quick Repair and Rebuild"

    After that run "Rebuild Sugar Logic Functions", go to Studio, select any module and any field, click the checkbox "Calculated" in order to open the formula builder and double check if this custom sugarLogic function is available.

    If it is not, run again "Rebuild Sugar Logic Functions" and try again. Once you confirm it is available, you can use it anywhere.

    <?php
    /*
     * Your installation or use of this SugarCRM file is subject to the applicable
     * terms available at
     * http://support.sugarcrm.com/Resources/Master_Subscription_Agreements/.
     * If you do not agree to all of the applicable terms or do not have the
     * authority to bind the entity as an authorized representative, then do not
     * install or use this SugarCRM file.
     *
     * Copyright (C) SugarCRM Inc. All rights reserved.
     */
    
    /**
     * <b>currentUser()</b><br/>
     * Returns full name of the authenticated user. <br/>
     * ex: <i>currentUser()</i> = true
     */
    class currentUserExpression extends StringExpression
    {
    	/**
    	* Returns full name of the authenticated user
    	*/
    	function evaluate()
    	{
    		global $current_user;
    
    		return $current_user->full_name;
    	}
    
    	/**
    	* Returns the JS Equivalent of the evaluate function.
    	*/
    	static function getJSEvaluate()
    	{
    		return <<<EOQ
        		var genericApp = (SUGAR.App) ? SUGAR.App : app;
    
    	        return genericApp.user.get('full_name');
    EOQ;
    	}
    
    	/**
    	* Returns the opreation name that this Expression should be
    	* called by.
    	*/
    	static function getOperationName()
    	{
    		return "currentUser";
    	}
    
    	/**
    	 * Returns the maximum number of parameters needed.
    	 */
    	static function getParamCount() {
    		return 0;
    	}
    
    	/**
    	 * Returns the String representation of this Expression.
    	 */
    	function toString() {
    	}
    }
    

    André Lopes
    Lampada Global
    Skype: andre.lampada