web
You’re offline. This is a read only version of the page.
close
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

I have the same question (0)
  • Suggested answer
    Pradeep Rai Profile Picture
    5,489 Moderator on at

    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

  • Inogic Profile Picture
    703 on at

    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
    Naveen Ganeshe Profile Picture
    3,397 User Group Leader on at

    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();
    }

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 74 Super User 2025 Season 2

#2
Daniyal Khaleel Profile Picture

Daniyal Khaleel 32 Most Valuable Professional

#3
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 31 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans