Referencing a field in parent record when creating new linked record

I am trying to create a task with an action button on the opportunities module, i want the subject of the new related task to be a concat of some fixed text and a value from the parent opportunity the button is being clicked on. The button works in creating the task but only the prefilled text is added to the subject, my attempt to pull the field value from the opportunity is always blank. Current calculation is: 

concat(string("Test Statement-"),string(related($opportunities, "pr_quotewerks_id")))

Does anyone have any advice, i feel like it isn't possible as this isn't the first time i've tried however i hope i am wrong. It doesn't seem like a very "outside the box" idea.

Thanks All

  • Hello  ,

    The formula that you are using is correct, when placing a similar one in a calculated field the Related record does render as expected: 

    https://www.screencast.com/t/nxlReRCVv

    Investigating open issues I did come across the following pertaining Action Buttons that believe is similar:

    #90036 ( portal.sugarondemand.com/90036 )



    My recommendation for you would be to create a case for our support team to make sure it's the same to make sure that you are posted on the issue resolution process. 


    While this is not fixed, I though about a workaround.
    The only thing that crosses my mind is the following:  



    1 - Create a checkbox field on the Tasks module to indicate Tasks that are being created by your Action Button. 

    The field doesn't need to be shown to the users, make sure you set it to Selected in the Action Button Settings: 

    2- After having that you can use a SetValue Dependency to populate the Subject of the Task with your formula when the checkbox is checked. 

    It Tried something like this and it works:

    <?php
    
    //path custom/Extension/modules/Tasks/Ext/Dependencies/task_created_action_button.php
    
    $dependencies['Tasks']['created_action_button'] = array(
        'hooks' => array("edit", "view"), //not including save so that the value isn't stored in the DB
        'trigger' => 'equal($created_action_button_c,true)',
        'onload' => true, //Whether or not to trigger the dependencies when the page is loaded
        'actions' => array(
            array(
                'name' => 'SetValue',
                'params' => array(
                    'target' => 'name',
                    'value' => 'concat(string("Test Statement-"),related($opportunities,"description"))'
    
                )
            )
        )
    );



    Just make sure to adapt the field names to the ones on your instance. 

    Let me know if this works for you. 

    Cheers, 

    André 

  • Hi Andre,

    Thanks very much for the help there, i am unfortunately going to have to adapt your work around as i do not have the level of access to work on the code like you provided. Instead i will follow the same idea and use a process definition to combine the two pieces of text and then clear the checkbox and helper text field. It is a pain but have set it up and works exactly as intended. Thanks for the inspiration!

  • Hello Sam, 


    Great, I am happy you've worked it out. 
    Regarding "access to work on the code", if you have instance admin access normally you should be able to upload modules via Module Loader. Something like this should help as a example on how to upload a custom file:

    https://support.sugarcrm.com/documentation/sugar_developer/sugar_developer_guide_13.1/cookbook/module_loadable_packages/creating_an_installable_package_that_copies_files/

    But if you have it working already, I'll leave just as a future reference. 
    Wishes of a great rest of the week. 

    Cheers, 

    André