Media calls using a script looking at detail

I need to write a script that changes the media on the middle sheets of a document. I need to look at the detail record to see if it says “Page 1 of”. There will be several page 1 in the detail record. There is 1 detail record for each physical page that prints.

This is what I currently have, but this would just loop through it all and give me the last detail record value.
How do I know what detail record, I am currently on?

for(let i=0; i< record.tables.detail.length;i++){
if(record.tables.detail[i].fields[“page numbers”]==(“Page 1 of”)) {
results.attr(“content”,“perforated”)
} else {

results.attr("content","plain");}

}

image

Hi @diane,

I assume that you are looking for the following solution:

  1. Right click on the Print Context Section (in the Resource pane) and click on the option “Properties…” to open the Properties window.
  2. Go to the Sheet Configuration tab once the Properties window has been opened.
  3. Uncheck the option “Same for all positions”
  4. Change the media of Middle Sheet to the media you would like to use for, and I quote: “the middle sheets of a document”.

Can you please confirm if this correct?

I have that box already unchecked. With in the Middle sheets- I need to pull to different kids of media depending on a field in a nested table. If I see Page 1 of, I need to pull a perforated sheet else I need to pull a plain sheet. There will be several Page 1 of in the document. I can’t figure out how to find out what subrecord that I am on to look at that field.

Hi @diane,

Is it possible to share the Data Mapping Configuration and Template files as anonymised data?

I don’t have that kind of data to share. So let me word this a different way. Every detail record, is a physical page for the document record. The number of pages vary for each document so the number of detail records very. On the media calls- I need to look at that detail record and decide what media to use. So the first page of the document would be perforated, page 2 - plain, page 3- perforated- page 4 - perforated. There is no set pattern, but I have all of the information stored in the detail record. So the first page of the document I need to use the information from the fist detail record of the and then the second page the 2nd detail record for that document. How do I know what page of the document I am on in the script for the media calls to look at that same detail record?.

I assume that this is not possible without cloning (‘Dynamically adding sections (cloning) - PReS Connect 2021.2 User Guide (link)’).

Can you let us know please what kind of file you’re using as Data Sample–is that for example a XML file or PDF document–and what each page contains as data?

We are using a pdf as the data source. I am not changing the pdf when I print except for adding a barcode and a few other indicators on the document. With this instance- I am trying to house hold the documents manually instead of using the grouping in the presets for various reasons- I have created a new boundary that is working properly to group all of the data. I created a detail record for page of the document (nested table). Would it be best to just open a ticket for help?

Hi @diane,

Yes, indeed. I assume that it will be the the best to open a technical support ticket via our website.