Copy to Clipboard
Hello,
I would like to add a Button to my Workflow which copies a string value to the clipboard of the OS.
Since I haven't found any specific activity for that purpose, I tried using the expression evaluator with the following sample code:
=(function(text) {
navigator.clipboard.writeText(text)
.then(() => {
console.log('Copied to Clipboard: ' + text);
})
.catch(err => {
console.error('Failed to copy: ', err);
});
})('Sample Text');Unfortunately I get an error in the Log saying:
Failed to execute command ["sandbox-helper.run-workflow-from-designer"]: Cannot read properties of undefined (reading 'clipboard')
So it seems like I cannot adress the navigator object through the expression evaluator.
Is there some other way to copy information to the clipboard?
And yes, I know there are already posts in the community and in the idea section, but without conclusions and pretty old.
Greetings,
Chris
-
You can only access the navigator object through the window, it is not a top-level property.
Copy this to the Expression of an Evaluate Async activity:
=window.navigator.clipboard.writeText("clip")2 -
Thank you Berend,
that works perfectly!
Finished the week by learning something.0
Vous devez vous connecter pour laisser un commentaire.
Commentaires
2 commentaires