Exactly what expression are you using in the web viewer to display the selected PDF?
I think we can come up with a method where that URL calculation can evaluate to a null value when it's not the current record. That would limit you to just one PDF open at a time in only the current web viewer.
I have multiple webviewers on each record that are placed on different tabs. An example of an the expression I use for one of the URL calculations would be
"file://P:/MECH TESTING CERTS/" & MTRS::USB#: & "-" &MTRS::Lot& " MECH.pdf"
Where MTRS::USB#: and MTRS::Lot are fields that hold values specific to each record.
If something could be aded to the expression where it defaults to a null value when I am not currently on the record that contains that information, I think that would work perfectly.
you could use a global field into the WebViewer calculation, something like:
globalField = Get ( RecordID ) ; "file://P:/MECH TESTING CERTS/" & MTRS::USB#: & "-" &MTRS::Lot& " MECH.pdf"
and use an OnRecordLoad trigger to populate the global field with Get ( RecordID ) .
What view is this layout in? List view or Form view?
You talked in terms of limiting the viewer to the current record, but now I wonder if you ment the "current tab".
The basic expression you can use inside the web viewer is:
If ( //some test goes here ; "file://P:/MECH TESTING CERTS/" & MTRS::USB#: & "-" &MTRS::Lot& " MECH.pdf" ; "" )
But there are different expressions you can use where I have "// some test goes here", depending on whether this is for a different tabs, different records while in list view, or both.
@PhilModJunk, I'm always in form view for this database and I did mean records. I don't have enough tabs in each record to have any issues with overloading the webviewer (I shouldn't have thrown that information in to my previous post, it wasn't really relevant)
@raybaudi, so if the record id doesn't match (in the other records im not currently on) it would stop evaluating that expression and close out the pdf?
I don't see how this problem can occur in form view, but then I haven't tried this either to test.
Raybaudi and I are posting very similar examples here (case and IF function exactly the same here). If I'd seen his post first, I wouldn't have posted mine.
I'm trying to write the script that populates globalField with the recordID but I can't find the option to do that. What I've been trying to do is....
Replace Field[MTRS::globalField] but when I go into the calculations there is no get(record id) function option. I have the same issue when I try to do it using the Set Field option. I know I'm doing something very simple incorrectly.
Replace Field Contents modifies the same field for all records in your found set, so this is not the step you want here.
Set Field [MTRS::GlobalField ; Get ( RecordID ) ]
should do the job.
When Setting up Set Field, there are two Specify buttons that must be clicked. To get Set Field [Table::Field ; Expression], add set field to your script and click the first button (specify target field). Select Table::Field from the list of fields. Click OK. Now click the lower specify button (calculated result) and create the expression to the right of the semicolon (;). Do not try to type in the semicolon.
I used the expression that had been suggested and unfortunately it did not work. I have copy and pasted the expression that I used, in case it is because of a typo that I made or something.
Case( MTRS::globalField=Get( RecordID) ;"file://P:/MECH TESTING CERTS/" & MTRS::USB#: & "-" &MTRS::Lot& " MECH.pdf")
I tested the expression by scrolling through the records and allowing the pdf to pop up in the webviewer next to the test report, as I got to record 58, I got this message, "The maximum number of files are already open. No other files can be opened or printed until some are closed." and the webviewer just showed a blank window. Any record I scrolled to after that (that I had not already scrolled through) popped up with the same message. If I went back and looked at the records I had preciously scrolled through, the pdf immediately pops up in the webviewer without even loading which telles me that it is not closing when I move on to a new record.
Just to help give a visual of what my database looks like. I have a test report on the left which is where information would get typed into or get pulled to. Then I have a tab control on the right and on the very first tab is a webviewer that shows a pdf that is associated with that particular test report (or record). So a pdf is popping up in the webivewer as soon as I scroll to a record that has a test report that has already been filled out.
Any ideas on where I'm going wrong?
Did you set the OnRecordLoad trigger ?
Since you are in form view, I don't think anything evaluates on the other records in your found set--including the above expression. I can't speak for Raybuadi, but I'm basically suggesting experiments to you that may or may not work.
Let's try two other, more extreme options to see if they make a difference:
As a test, try limiting your found set to just the current record. Instead of moving from record to record, try performing a find to change records, bringing up one record at a time. See if you still get this error. If it does, this may be something to report in the Report an Issue section of the forum.
If that appears to work, we can try this approach:
Modify the expression to use a local field instead of a global field to get:
Case( MTRS::Switch ;"file://P:/MECH TESTING CERTS/" & MTRS::USB#: & "-" &MTRS::Lot& " MECH.pdf")
Now add two buttons, Open and Close to your layout. On can be set up to do this: Set Field [MTRS::Switch ; True ]. Off would be: Set Field [MTRS::Switch ; False ].
For this test, discipline yourself to click Open to view the PDF, then click Close before changing records and see if you still get this error message.
What may make this an issue to report is that the web viewer's URL opens the PDF, but redirecting it by changing the URL expression, may not do anything to close the PDF, leaving it open in the background.
Yep, but maybe I set it in the wrong place? (not sure if that's even possible)
I went to file, manage, manage layouts, chose the MTRS layout, went to the script triggers tab, chose OnRecordLoad and then I chose the script, PDF Window Control.
The PDF Window Control Script is just, Set Field [MTRS::globalField; Get (RecordID)]
I don't see any errors, it's just that this will only affect the current record when you are in form view. It doesn't "turn off" anything in the other records as they are not visible on your layout. In list view--what I originally thought was the situation here, this migth change as you could have more than one record visible at a time.
I really suspect that we've bee chasing up the wrong tree here. If you think about it, your web viewer does the same basic thing as an Open URL script step, but displays the results in the web viewer instead of in a new window. With Open URL, you have direct control of whether you close or leave open any given PDF by whether you leave the window in which it was opened or if you close it. What is not clear here, is what happens to the PDF you opened when the viewer is redirected to another location (such as the null value). My suggested tests are intended to discover whether redirecting the viewer actually closes the file or if it remains open.