web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

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

Click to Copy Button for each field.

(0) ShareShare
ReportReport
Posted on by 70

Some complex fields like Optionset, Lookup and Date fields are not to copy and paste. I would like to have a Copy button beside each field and the user can copy the value or label of the field with a click that button. How do I do that?

Sample Copy Button

pastedimage1626360372173v1.png

I have the same question (0)
  • Suggested answer
    Wahaj Rashid Profile Picture
    11,321 on at
    RE: Click to Copy Button for each field.

    Hi,

    Thank you for your query.

    There is no out-of-the-box option for this purpose.

    I also do not see any PCF control that will full this requirement.

    You can try building an HTML Web resource or your own PCF control to provide this functionality.

    In short, there is no easy for it.

  • Dyname365 Profile Picture
    70 on at
    RE: Click to Copy Button for each field.

    Thanks I will read up more on both methods.

    Trying to find the best ways to achieve this.

  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Click to Copy Button for each field.

    Hi,

    You need to create web resources(buttons) for the fields you want to copy and add an onClick event via standard JS.

    To copy to the clipboard, you can use the following code:

    document.getElementById('').onclick = function copy() {
        var copyText = window.parent.Xrm.Page.getAttribute("new_startdate").getValue();
                    
        var objectText = document.createElement('input');
        document.body.appendChild(objectText);
        objectText.value = copyText;
        objectText.select();
        document.execCommand("copy", false);
        objectText.remove();
        alert("Copied the text: "   objectText.value);
    }
    

    Result:

    pastedimage1626413145496v1.jpeg

  • Dyname365 Profile Picture
    70 on at
    RE: Click to Copy Button for each field.

    Thanks. That is helpful. I will try as soon as I get a chance.

  • Suggested answer
    meelamri Profile Picture
    13,216 User Group Leader on at
    RE: Click to Copy Button for each field.

    Hi,

    Frank Gong's approach is not supported because it uses DOM manipulation...

    Another approach is to create two buttons: "Copy" and "Paste".

    Copy: When clicking on Copy, a dialog box will appear with the list of fields in your form. The user can select the fields to be copied.

    Paste: When the user clicks on Paste on the second form, all the fields selected before will be pasted

    Finally, you can use the browser session to store the values to be copied.

    I might try to implement this scenario... it seems like something practical.

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 159

#2
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 152

#3
Tom_Gioielli Profile Picture

Tom_Gioielli 134 Super User 2025 Season 2

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans