Customizing prefilled data when users click on duplicate

Hi There,

I know how to add new action menu button with custom code, but I can’t find out how and where to customize the common ‘duplicate’ function of the action menu of a module detailed view.
For instance, I want to customize the prefilled value of the ‘valid until date’ of a quote when duplicating it from an existing one.
Is there a way to to that?

Thanks a lot for your help

PB

I never looked into this before, but I think that logic is here

https://github.com/salesagility/SuiteCRM/blob/master/include/EditView/EditView2.php

specifically, check all references to this variable: isDuplicate

Now, that is a generic module, applies to all modules, so it might be tricky to get something done just for Quotes.

I think the Contacts module has some specific logic, overriding that class to do some additional work when duplicating:

https://github.com/salesagility/SuiteCRM/blob/master/modules/Contacts/views/view.edit.php

But one class is called EditView and the other extends ViewEdit, so something is escaping me here. I don’t have time now to do any additional searching, but I do hope that with this help you can find it out for yourself. :slight_smile:

1 Like

Hi pgr

Thanks for your reply.
Yes, of course this helps.

I could then find out an easy way to customize as an example the ‘expiration’ prefilled value when duplicating a quote, by modifying the file ‘modules/AOS_Quotes/views/view.edit.php’ (or place a copy in 'custom/modules/AOS_Quotes/views/ directory to be upgrade safe).

I just replaced the function display():


        function display(){
                $this->populateQuoteTemplates();
                parent::display();
        }

by this one:


        function display(){
                $this->populateQuoteTemplates();
                if (isset($_REQUEST['isDuplicate']) && $_REQUEST['isDuplicate'] == 'true' ) {
                        $this->bean->expiration=date('d/m/Y', strtotime("+30 days"));
                }
                parent::display();
        }

I am not sure it is the best way to do this, but it works.

Thanks a lot :slight_smile:

PB

2 Likes