Skip to main content
Inspiring
July 31, 2019
Answered

Can I " no print " text fields on page 1 and 2 but print them on page 3 code I have below so far

  • July 31, 2019
  • 2 replies
  • 729 views

Hi all, I would like to not print Button2 & Text8c on page 1 and 2 but have them print on page 3. At the moment they dont print on page 3 due to noprint is this possible.

Thanks for your help

//select fields & Buttons before Printing.

for (var i=0; i<this.numFields; i++) {

    var f = this.getField(this.getNthFieldName(i));

    if (f==null) continue;

    if (f.type=="button") f.display = display.noPrint;

    if (f.type=="field") f.display = display.noPrint;

}

//Buttons & fields to not print

getField("Button2").display = display.noPrint;

getField("Text8c").display = display.noPrint;

var pp = this.getPrintParams();

pp.DuplexType = pp.constants.duplexTypes.DuplexFlipShortEdge;

this.print(pp);

This topic has been closed for replies.
Correct answer Panospano

Ok - I have got this working after mucking around for anybody who needs this for future reference :-

//Hide Buttons before printing.

for (var i=0; i<this.numFields; i++) {

    var f = this.getField(this.getNthFieldName(i));

    if (f==null) continue;

    if (f.type=="button") f.display = display.hidden;

}

//hide field

getField("Text8c").display = display.hidden;

getField("Button2").display = display.hidden;

//TO PRINT

this.print({

bUI: false,

bSilent: false,

bShrinkToFit: true,

nStart: 0,

nEnd: 1,

});

for (var i=0; i<this.numFields; i++) {

    var f = this.getField(this.getNthFieldName(i));

    if (f==null) continue;

    if (f.type=="button") f.display = display.visible;

}

//display field and butons again

getField("Text8c").display = display.visible;

getField("Button2").display = display.visible;

this.print({

bUI: false,

bSilent: false,

bShrinkToFit: true,

nStart: 2,

nEnd: 2,

});

2 replies

Bernd Alheit
Community Expert
Community Expert
August 1, 2019

Give the fields different names. Then you can assign different properties to the fields.

PanospanoAuthor
Inspiring
August 1, 2019

Bernd, I have the fields as different names, please explain.

I think I now what you mean about get fields on page 1 & 2 and three having the same name.

The user fills in getfield 8c which echos the same information on page 3 the same goes with the button and when I print I need it to hide the field & button on page 1 but be visible on page 3 for printing

Anyway unless you have some sort of  new code, I am happy that I have it working the way I have, it might not be elegant but it works now. LOL :-))  Now my mind needs a rest

PanospanoAuthorCorrect answer
Inspiring
July 31, 2019

Ok - I have got this working after mucking around for anybody who needs this for future reference :-

//Hide Buttons before printing.

for (var i=0; i<this.numFields; i++) {

    var f = this.getField(this.getNthFieldName(i));

    if (f==null) continue;

    if (f.type=="button") f.display = display.hidden;

}

//hide field

getField("Text8c").display = display.hidden;

getField("Button2").display = display.hidden;

//TO PRINT

this.print({

bUI: false,

bSilent: false,

bShrinkToFit: true,

nStart: 0,

nEnd: 1,

});

for (var i=0; i<this.numFields; i++) {

    var f = this.getField(this.getNthFieldName(i));

    if (f==null) continue;

    if (f.type=="button") f.display = display.visible;

}

//display field and butons again

getField("Text8c").display = display.visible;

getField("Button2").display = display.visible;

this.print({

bUI: false,

bSilent: false,

bShrinkToFit: true,

nStart: 2,

nEnd: 2,

});