Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested answer

clone button on form toolbar which clones the record on subgrid

(0) ShareShare
ReportReport
Posted on by 5

Need to know how to implement cloning functionality on a button added by Ribbon. As I will be adding subgrid on form and on clicking clone button it should copy the records on subgrid

  • Suggested answer
    Naveen Ganeshe Profile Picture
    3,393 User Group Leader on at
    RE: clone button on form toolbar which clones the record on subgrid

    Hi,

    To implement the cloning functionality on a button added by Ribbon in Dynamics 365 CRM, you will need to perform the following steps:

    1. Create a JavaScript function that will handle the cloning functionality. In this function, you will need to retrieve the selected records from the subgrid and then create new records with the same data.

    2. Add the JavaScript function to a web resource in Dynamics 365 CRM.

    3. Create a new button in the Ribbon using the Ribbon Workbench tool. You can add the button to the subgrid's ribbon or to the form's ribbon.

    4. In the button's properties, specify the JavaScript function as the OnClick event.

    5. Publish the changes to the Ribbon Workbench.

    6. Test the cloning functionality by selecting records in the subgrid and clicking the Clone button.

    Here is an example of a JavaScript function that could be used for cloning:

    function cloneSelectedRecords(executionContext) {
      if (executionContext === null) return;
            var formContext = executionContext.getFormContext();
    
        // Get reference to the subgrid control
        var subgridControl = formContext.ui.controls.get("your_subgrid_name");
        // Get the selected rows in the subgrid
        var selectedRows = subgridControl.getSelectedRows();
    
        // Iterate through the selected rows
        for (var i = 0; i < selectedRows.length; i  ) {
            // Get the data for the selected row
            var rowData = selectedRows[i].getData();
            // Create a new record with the same data
            Xrm.WebApi.createRecord("your_entity_logical_name", rowData).then(
                function (result) {
                    var newRecordId = result.id;
                    console.log("New record created with ID: "   newRecordId);
                },
                function (error) {
                    console.log(error.message);
                }
            );
        }
        // Refresh the subgrid to show the newly created records
        formContext.data.refresh();
    }

  • Inogic Profile Picture
    500 on at
    RE: clone button on form toolbar which clones the record on subgrid

    Writing code to implement cloning functionality can be a challenging tasks.

    Alternatively you can look at third party apps to clone your CRM records. You can clone your records in just one click by using our Microsoft-preferred 1-click app Click2Clone.  

    For instance, if you want to clone an opportunity, just click on the Click2Clone button, and you will have a clone of that opportunity in no time.

    This app will also assist you in creating multiple copies of a record. You can clone a single record as well as multiple records in one go by using our Microsoft-preferred app Click2Clone. Watch this video to explore how Click2Clone can help you in different ways with all your cloning requirements.

    To know more about Click2Clone download a 15-day trial from our website or Microsoft AppSource or write us at crm@inogic.com

    Thanks!

  • Suggested answer
    Pradeep Rai Profile Picture
    5,487 Super User 2025 Season 1 on at
    RE: clone button on form toolbar which clones the record on subgrid

    Hi,

    We can add ribbon button on Subgrid as Create Clone.

    After this we need to create, script, action and plugin as described in below link:


    https://balugajjala.wordpress.com/2017/06/01/clone-a-case-record/

    The flow will be like:-> Ribbon Button-> Script-> Call Custom Action in Script -> Plugin will get trigger(i.e. Registered plugin on custom action)-> Plugin will create clone record.

    Thanks,
    Pradeep.

    Please mark this as VERIFIED. If it helps

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Daivat Vartak (v-9davar) Profile Picture

Daivat Vartak (v-9d... 225 Super User 2025 Season 1

#2
Muhammad Shahzad Shafique Profile Picture

Muhammad Shahzad Sh... 106

#3
Vahid Ghafarpour Profile Picture

Vahid Ghafarpour 82 Super User 2025 Season 1

Overall leaderboard

Product updates

Dynamics 365 release plans