How to use function "windows.print() "print all the content in widget?

I am making a widget like the master widget “record history” , the widget some form and the form have more than 3 pages , in the widget i set a button to print use function “windows.print()” ,but it not work like follow pictuer ,so my quest how to do the same print buttong ?

When my widget run, click the print button the error as follow:
Uncaught TypeError: Cannot read property ‘document’ of null
and the button click function as follow:
function printpage() {
const newstr = document.getElementById(‘printTable’).innerHTML
const newWin =‘’)
console.log( newWin );
newWin.document.body.innerHTML = newstr
setTimeout(() => {
}, 300)

Hey @tintinding -

Good find, this is a bug that we haven’t run across yet. I made a big report for this on friday and a change to resolve this is in testing right now. The underlying limitation here is that window.print(); cannot be executed within the Iframe that a custom widget lives in.

I would expect to see this change roll out in r233 or r234 (rolling out the week of 8/25, and 9/8 - assuming there aren’t any delays).

Thanks for reporting this one!

Thank for your reply,do we have another way to print all the content in widget?

Hey @tintinding -

As far as I am aware, this command is the only way to open the windows print prompt-

The content of a widget can be output to a prop/event as base64 text, which could then be stored to an app image variable, or a table image field.


See edit below, releasing with r234, not r233

Confirmed this will be released in r233 rolling out at the end of next week. @tintinding.

Thanks for the patience-

@tintinding - Just 1 one note I want to make sure is clear-

Custom widgets run within an iFrame in your applications intentionally to help limit any risk of them impacting/accessing other elements of your application unintentionally. This is a decision that was very intentional, and its the same reason custom widgets cant do stuff like changing the color of a button on an app step, or changing what step you are on.

With r233 this printing limitation will be resolved, but that print call only has the access to what is in that iFrame, it still wont be possible to print a full app step from a custom widget, like you can from a trigger.

Hope this makes sense-

I got it, I will use widget to display content and use widget’s print button to print widget’s content, When r233 released how long can be install to private cloud .

See edit below, releasing in r234, not r233
Hey @tintinding -

You should be seeing this release on 7/25 assuming this release passes all of the QA work that is currently ongoing for it.

For anyone else seeing this-

Tulip updates are released in a tiered fashion across the release week. r233 should be going out next week, but you may see it as early as 7/22 or as late as 7/31

Again - Release is in testing right now, so these dates are subject to change


Hey @tintinding -

Got wires crossed. this will be coming out with r234 which should be releasing on 8/8, but that date is subject to change.