Copy paste perspective table

When using the copy function of a perspective table it will copy the JSON of a row.
When this is pasted in an email, the data isn't shown logically to other people.
Is there a way to make the copy function copy the data and transform it to a table format that works for an email (or Word document for example).

Try exporting the data using this function:
https://docs.inductiveautomation.com/display/DOC81/system.dataset.exportExcel

1 Like

Still on the backlog :frowning_face:

I do get this but I want to use the clipboard instead of exporting.

Is there a possibility to create your 'own' copy function with a button?
Which takes this JSON and transforms it to HTML code and sets this HTML to you're clipboard so you can paste it in Outlook?

this js injection markdown allows you to copy text to the clipboard. This might require your client to accept clipboard access though. Also requires https and proabbly doesnt work all browsers. only testsed on chrome

you'll have to write the bindings value to something usefull yourself, best to write to a custom component only filled by the button or something. and clear this property after this code so it doesnt accidantly fill up the clipboard when unwanted

[
  {
    "type": "ia.display.markdown",
    "version": 0,
    "props": {
      "markdown": {
        "escapeHtml": false
      }
    },
    "meta": {
      "name": "Markdown"
    },
    "position": {
      "x": 288,
      "y": 373,
      "height": 200,
      "width": 200
    },
    "custom": {},
    "propConfig": {
      "props.source": {
        "binding": {
          "type": "expr",
          "config": {
            "expression": "{../TextField.props.text}"
          },
          "transforms": [
            {
              "code": "\t\n\tif not value: return \"\"\n\t\n\tcode =  \"\"\"<img style='display:none' src='/favicon.ico' onload=\\\"\n\t\tnavigator.clipboard.writeText('\"\"\"+value+\"\"\"');\n\t\t\t\t\n\t\\\"></img>\"\"\".replace(\"\\n\", \"\").replace(\"\\t\", \"\")\n\treturn code\n\t",
              "type": "script"
            }
          ]
        }
      }
    }
  }
]

Hi @victordcq

I tired below code to copy the text in perspective. but its not copying to clipboard.
code i have return in button and launched the screen in chrome

value = 'testing'


	code = """
	    <img style='display:none' src='/favicon.ico' onload='navigator.clipboard.writeText("{value}");'></img>
	"""
	
	return code

whether i am missing something?

The reference script inject js using markdown. Verify you are also doing same.
image

1 Like

Yes this does nothing.
You also should use the replace on the tab/newlines i use
Just copy the example

For testing purpose i tired your script but its returning null

anything wrong?

the code in my post is to be pasted inside the view, its the markdown component + the binding with the script

Ok what i am trying is when user click button i want to copy the text from label that's it.
can you guide me for this please

Copy the code, directly into the view, this should create the markdown + the binding. Change the binding input to some custom prop.
Write your value to this custom prop on your button click.
(Clear the custom prop after, since in the binding it checks there is a value or not, this should stop triggering the js)

1 Like