cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - You can Bookmark boards, posts or articles that you'd like to access again easily! X

Windchill customization, copy checkin comment to clipboard

Mat
13-Aquamarine
13-Aquamarine

Windchill customization, copy checkin comment to clipboard

Hi there,

 

the default behavior of windchill is, that if somethings goes wrong during checkin process, the checkin comment is lost.

So I tweaked  <Windchill-installation>\codebase\templates\uwgm\cadx\checkin\checkintables.js a little to make a copy of the comment to a new window like:

 

var comment_window = window.open();
comment_window.document.writeln(comment);

(I intentionally left all code out, which "prettifies" the new window)

  works great!

 

Now I want to copy the comment directly to the clipboard.

But when I try this

// copy comment to clipboard

		navigator.clipboard.writeText(comment)
		.then(() => {
		        alert("successfully copied: " + comment);
		   })
		  .catch(() => {
			alert("something went wrong");
		   });

 I get the error under Creo 8.0.6.0, "checkintables.js Uncaught TypeError: Cannot read properties of undefined (reading 'then')"

 

What am I doing wrong?

1 ACCEPTED SOLUTION

Accepted Solutions
Mat
13-Aquamarine
13-Aquamarine
(To:Mat)

Ok, I think I found the solution

 

There is an article at w3docs.com about that.

https://www.w3docs.com/snippets/javascript/how-to-copy-the-text-to-the-clipboard-with-javascript.html

 

The third and last method works within Creo's embedded browser.

 

...
copyTextToClipboard(comment);
...
}

async function copyTextToClipboard(text) {
	try {
	  await navigator.clipboard.writeText(text);
	  console.log("Text copied to clipboard " + text);
	} catch(err) {
	  console.log('Error in copying text: ', err);
	}
  }

View solution in original post

1 REPLY 1
Mat
13-Aquamarine
13-Aquamarine
(To:Mat)

Ok, I think I found the solution

 

There is an article at w3docs.com about that.

https://www.w3docs.com/snippets/javascript/how-to-copy-the-text-to-the-clipboard-with-javascript.html

 

The third and last method works within Creo's embedded browser.

 

...
copyTextToClipboard(comment);
...
}

async function copyTextToClipboard(text) {
	try {
	  await navigator.clipboard.writeText(text);
	  console.log("Text copied to clipboard " + text);
	} catch(err) {
	  console.log('Error in copying text: ', err);
	}
  }

Top Tags