-1

This is the first time I'm encountering GetLayoutObjectAttribute and I am having serious issues with it. My variable $web won't set. I think it's because PD_WebV isn't the right object name to refer to, but I don't know how to find the right object name. I can't find the objects name when I hit Edit Layout, so does anyone know how to find an layout objects name?

Loop
     Pause/Resume Script [Duration (seconds): 1]
     Set Variable[$Web; Value: GetLayoutObjectAttribute("PD_WebV";"content")]
     If[$Web="done"]
          #execute if statements

enter image description here

After Edit:

After some troubleshooting, I found out that PD_WebV is the right object name to refer and it's refered to correctly, so my new question is why doesn't the script go to the line If[$Web="done"] and how could I fix it? Ss my If statement not evaluating something it should be? Is my $web variable never set to done or is the issue something completely different? Would the problem possibly have to do with my WebDirect sharing settings? Any guidance would help. Thanks.

After, After Edit: So now that my application is getting past Set Variable[$Web; Value: GetLayoutObjectAttribute("PD_WebV";"content")], the variable $web only equals <HTML></HTML>. Does anyone know a way, without using javascript, to test the inside of the html tags?

Also, I printed the bounds of the webViewer PD_WebV that I can't locate on the layout but am referring to in the script. The bounds that are printed are different each time I run the script. Is the usual or unusual? My source is also about:blank so it doesn't look like I'm sourcing from a URL

Bobby
  • 1,585
  • 3
  • 19
  • 42
pHorseSpec
  • 1,246
  • 5
  • 19
  • 48
  • What version of FileMaker are you using? – Chris Schmitz Jul 24 '15 at 20:21
  • Filemaker 14 my friend, but I also have 13 still installed since 13 is 32 bit and 14 is 64 bit – pHorseSpec Jul 24 '15 at 20:22
  • Gotcha, and did you add the name `PD_WebV` to your WebViewer's **Name** field in the inspector? – Chris Schmitz Jul 24 '15 at 20:25
  • 1
    In that screenshot you posted, the place where you have "ProjWonPortal" is your layout object name. If you were going to use `GetLayoutObjectAttribute` on it, it would look like this: `GetLayoutObjectAttribute("ProjWonPortal"; "content")` – Chris Schmitz Jul 24 '15 at 20:43
  • Yea, that was a different layout object, but thx for the info – pHorseSpec Jul 24 '15 at 20:45
  • Ah gotcha. Np and good luck. – Chris Schmitz Jul 24 '15 at 20:46
  • Thx. i'm going to need it – pHorseSpec Jul 24 '15 at 20:46
  • "*the variable $web only equals *" That doesn't tell us anything, one way or another. What do you see if you load the same page in a browser, then choose "View Page Source"? – michael.hor257k Jul 28 '15 at 23:08
  • The real issue I'm having is locating this webviewer that doesn't seem to be anywhere on the page. I even printed the bounds of the webviewer, and I clicked the area between the stated bounds and nothing seemed to be there. Is there any layout tricks to hide webviewers? Also, I'll probably open this up to a new question. Thanks for your help. It's greatly appreciated and you'll be getting the +50 bounty. I'm just keeping the question open for a little longer so it may get more attention. – pHorseSpec Jul 29 '15 at 13:53

2 Answers2

2

Is my $web variable never set to done or is the issue something completely different?

If you're doing:

Set Variable[$Web; Value: GetLayoutObjectAttribute("PD_WebV";"content")]

then the only time

$Web="done"

will return true is when the web page loaded into your web viewer contains exactly the string "done" (in practical terms, that's never).

I have already suggested in a comment that you test for:

PatternCount ( $webpage ; "</html>" )

This is assuming you want the subsequent steps to execute only after the page has finished loading. The entire script would look something like this:

Loop
     Pause/Resume Script [Duration (seconds): 1]
     Set Variable[$Web; Value: GetLayoutObjectAttribute("PD_WebV";"content")]
     Exit Loop If [ PatternCount ( $webpage ; "</html>" ) ]
End Loop     
# execute statements

You might also want to add a counter to the loop and exit the script after n trials.

michael.hor257k
  • 113,275
  • 6
  • 33
  • 51
  • Before, I put your `Exit Loop If [ PatternCount ( $webpage ; " – pHorseSpec Jul 28 '15 at 20:18
  • @pHorseSpec Is your question not answered? – michael.hor257k Jul 28 '15 at 21:46
  • yea, you answer my `After edit` question, but I'm not getting any HTML from my webviewer other than ``, so I'm trying to figure out how to create an if statement based on what's inside the html tags while not using javascript because it's not my strongest language. – pHorseSpec Jul 28 '15 at 22:05
  • "*I'm not getting any HTML from my webviewer other than *" I don't see how I can help you with that without more information. Perhaps you should post a new question (and close - again - this one). – michael.hor257k Jul 28 '15 at 23:03
1

Ah, I reread your question.

To set the object name for your webviewer so that the GetLayoutObjectAttribute function works you need to set it in the Name field in the inspector when you have the webviewer selected.

e.g.:

enter image description here

After that your variable should populate.

Be aware

What it will populate with will be all of the html from the browser, i.e. not a boolean true/false liek your conditional suggests.

I'm not sure exactly what you're trying to accomplish, but to be able to determine a result from your web viewer you'll need to either parse the HTML to see if it's content contains what you're looking for or within the code you're setting the webviewer with, fire a javascript function that calls back to the FileMaker file using a FileMaker url.

Chris Schmitz
  • 20,160
  • 30
  • 81
  • 137
  • Is the `Name` field the top field in the position tab of inspector? – pHorseSpec Jul 24 '15 at 20:35
  • 1
    Yep, that's correct. That name field is really the "layout object name" field. – Chris Schmitz Jul 24 '15 at 20:36
  • Would `If [not (IsEmpty ($Web))]` be better? – pHorseSpec Jul 24 '15 at 20:38
  • No, the problem is that even if whatever you set to the web viewer fails, html will still be generated (the webviewer still need to build something to show you that it failed) so it will always be full. Check out this article from Soliant Consulting on [javascript in in the webviewer](http://www.soliantconsulting.com/blog/2014/04/getting-started-javascript-and-filemaker) as far as getting data back out. – Chris Schmitz Jul 24 '15 at 20:41
  • @pHorseSpec In most cases, you would do something like `Exit Loop If [ PatternCount ( $webpage ; " – michael.hor257k Jul 24 '15 at 23:13