Razor

Images Not Always Appearing in Print

Discussion created by Razor on Sep 14, 2016
Latest reply on Sep 16, 2016 by taylorsharpe

I have an issue with a label that has a QR code on it. My problem is when I print a batch of labels I sometimes get labels without the QR code on them. It appears the print command executes before the record completely loads in to the layout. From a little experimenting it appears I can fix this by adding a pause statement before the print, but this doesn’t seem right to me.

 

To me it seems more like a band-aid than a fix. Maybe this is an accepted practice but I don't like it because what may work today might not be long enough under some other condition 6 months down the road.

 

Here is how this works. After the user enters revision, quantity, and the number of labels to be printed in the parent layout, they click the print button. My script then runs like this;

  • Set variables from the first record to capture the part master ID, part revision, and quantity.
  • Set a counter variable
  • Start loop
    • Generate the QR code from the record’s UUID. This is done with a Perform Script on Server command with the option set to wait for completion. There is a reason why this runs from the server which for simplicity's sake I will not get in to here.
    • Commit the record
    • Go to label layout
    • Pause (currently .1 seconds)
    • Print label
    • Go to original layout
    • Check to see if counter value has been hit, if not increase by one
    • New record request
    • Populate part master ID, part revision, and quantity fields
    • Commit records
    • Refresh window
  • End Loop

 

If I remove the pause I get all sorts of different results. Sometimes my first label won’t have the QR code, sometimes its the 3rd and 4th, but the 5th will print fine. There’s no apparent pattern.

When I go to check, all my records in the table have the QR code in them. So that part of my script is working great.

 

Is there some type of command to check and see whether the record is fully loaded in to the layout before printing?

 

Is there a better way of doing this?

Outcomes