Skip to main content
May 16, 2024
Question

Button for Copy text to clipboard

  • May 16, 2024
  • 4 replies
  • 1 view

Hello, guys. I am wondering how can I craete a component that has a button to copy its text content to the user's clipboard.

I would like to be able to copy the rich text's content only.

a!columnLayout(
  contents: {
    a!richTextDisplayField(
      label: "Lorem Ipsum",
      labelPosition: "ABOVE",
      value: {
        "Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt."
      },
      marginBelow: "NONE"
    ),
    a!buttonArrayLayout(
      buttons: {
        
        a!buttonWidget(
          label: "Copy to clipboard",
          submit: false,
          width: "MINIMIZE",
          style: "LINK"
          
          
        )
      },
      align: "CENTER",
      marginAbove: "NONE",
      marginBelow: "NONE"
    )
  }
)

If there's any coding answer for its implementation, I would much appreciate it.

4 replies

stefanhelzle0001
Brainy
May 16, 2024

Appian does not support this officially. But I think you should be able to find an unsupported hack using the search function.

mikes0011
Brainy
May 16, 2024

Agreed and in this case it's even less of a "hack" than normal - it's a built-in appian function (named specifically for its use case and in use in the designer back-end) which people have gradually figured out how to use in a SAIL interface (if unsupported).

May 16, 2024

a!richTextDisplayField(
  labelPosition: "COLLAPSED",
  value: {
    a!richTextItem(
      text: ri!textToCopy,
      style: "STRONG",
      size: "MEDIUM"
    ),
    char(9),
    a!richTextIcon(
      icon: "clone-solid",
      size: "MEDIUM",
      link: 'type!{http://www.appian.com/ae/types/2009}CopyToClipboardLink'(
        textToCopy: ri!textToCopy
      ),
      linkStyle: "STANDALONE"
    )
  }
)

By the way, a team-mate found this, hope it's useful for you all.
Source: community.appian.com/.../134831

peter.lewis
Employee
May 17, 2024

I'll add my standard disclaimer here - this is not a documented capability and is not officially supported. Any function or type like has not gone through the rigor / testing that supported functionality has and is subject to change in any release without notice.