14 Replies Latest reply on Oct 27, 2012 2:16 PM by PeterMontague

    Getlayoutobjectattribute function



      Getlayoutobjectattribute function


           I have a generic way of getting to a webpage. It works for all fields. This is the parent webpage. But the child webpage name doesn't seem to follow a reliable pattern. So I need to get to the child webpage by clicking on the link or else by copying the link from the source code in the web viewer.

           I believe this can be done using the Getlayoutobjectattribute function. Am I right? Is it then possible to parse, using this function into the various fields from the web viewer?

        • 1. Re: Getlayoutobjectattribute function

                    OS Version? Filemaker Version?

                    A Google for "Getlayoutobjectattribute parsing"

                    FROM LINK #1

                    You can create a button that will "get" the contents of the web view via the GetLayoutObjectAttribute function.
                    First, give the web view object a name.
                    Next, create a script that sets a field or variable using:
                    GetLayoutObjectAttribute(objectName;"source") -- returns the URL of the object
                    GetLayoutObjectAttribute(objectName;"content") -- returns the current content of the object (html, xml, etc.)
                    Now create a button which calls the newly created script.
                    if you're going to parse xml, take a look at http://www.briandunning.com/cf/1 for a function to simplify parsing.

                    FROM LINK #3

          On 25 Feb, 10:55, "MichaelR" <michaeliru...@gmail.com> wrote:
          > There was a very useful thread a few months ago called
          > "GetLayoutObjectAttribute" which had a nice technique for ensuring
          > that when you wanted to parse the HTML content of a Web Viewer object
          > you could wait until the content was available using a simple Loop.
          > I have used this technique and it works perfectly. Thanks to Howard
          > Schlossberg!
          > However, I need to use something similar for a database that is being
          > published using IWP and for some reason, when I evaluate the
          > GetLayoutObjectAttribute("wv";"content") function, and display it on
          > screen in IWP (for debugging) Filemaker does not return the source
          > HTML as I would expect and hope. It returns the URL! This is not much
          > use to me as I need to parse the HTML return of a PERL script running
          > on a remote server before the database can carry on with its work.
          > Has anybody tried to use this or have any ideas how I can work around?
          > Many thanks in advance for any help
          > Michael
          Well, turns out it is a limitation in FM 8.5. 
          It is there in the small print in the Web Publishing Guide. 
          I always find it quite annoyingwhen you get these seemingly arbitrary flaws in functionality.
          Anyway, on the plus side, Troi's URL plugin does not seem to suffer the same problem with its GetURL command. 
          Need to test a bit more but looks like a much more capable tool for manipulating web pages, even
          if it can't render them! I guess the plugin and the web viewer together are a pretty good combo though.


          • 2. Re: Getlayoutobjectattribute function

                 Thanks David. Link 1 looks interesting. How do you name a web viewer object. I don't see an option to do this in the manage database window.

            • 3. Re: Getlayoutobjectattribute function

                   Hi Peter,

                   You can assign a name to any object by selecting it in Layout mode and entering the name on the Inspector's Position tab (version 12) or on the Info pallet in previous versions.

              • 4. Re: Getlayoutobjectattribute function

                     I tried following that but its not working. I'm using FMPA 12 on the Mac osx platform. I am able to name the webviewer object on the inspector's position tab. But I can't see it in the list of fields when I go to specify the calculation. When I name it without specifying the field in this way Filemaker tells me that the field couldn't be found.

                • 5. Re: Getlayoutobjectattribute function


                       The webviewer is not a field but rather an object on your layout.  After you have assigned a name to the webviewer object you can use that  object name in the  GetLayoutObjectAttribute function:


                  objectName - the name of a named layout object on the current layout.
                  attributeName - the name of a supported attribute (see below).
                  repetitionNumber - the repetition number (for repeating fields).
                  portalRowNumber - the number of the row in the portal.
                       See the FMPA 12 Help on GetLayoutObjectAttribute for more details.  The attribute name you need to use is "content"
                  content - returns the content of the specified object as follows. For:
                  graphics - returns image data such as the name of a file in a container field if the image is stored (in the field or externally), or the reference to the file if the image is unstored.
                            In summary, you have to set a field (or better still a variable) to GetLayoutObjectAttribute("your_webviewer's_name"; "content"):
                            Set Variable[ $html ; Value:GetLayoutObjectAttribute("your_webviewer's_name"; "content")]
                  That said, there is a new function in FMPA 12 that is much easier to use than the GetLayoutObjectAttributes function.  Look up the scriptstep: Insert from URL.  It can insert the content of a given URL into a field without using a webviewer.


                  • 6. Re: Getlayoutobjectattribute function

                         I named the webviewer "parent". 

                         I want to set up a set field function which uses the getlayoutobject to get the source code or content of the web viewer. But when I enter the object name as "parent" it won't let me. 

                    • 7. Re: Getlayoutobjectattribute function

                      But when I enter the object name as "parent" it won't let me. 

                           Do you get an error message when you are trying to name the webviewer "parent"?  You may have already used "parent" to name another object on your layout.

                           Or do you get the error in your script when you are trying to enter:  Set Field [ your_table::your_field_name ; Value: GetLayoutObjectAttribute("parent" ; "content")  ??

                      • 8. Re: Getlayoutobjectattribute function

                             I type the following into the script.

                             GetLayoutObjectAttribute ( parent ; "content" )

                             I get this error message:

                             The specified table cannot be found.

                        • 9. Re: Getlayoutobjectattribute function

                               The object name must be placed between quotation marks:  "parent"



                               P.S.  You should try the Insert from URL scriptstep instead of GetLayoutObjectAttribute.  As i mentioned earlier, it's much easier to use.

                          • 10. Re: Getlayoutobjectattribute function


                                 GetLayoutObjectAttribute ( "parent" ; "content" )

                                 gets me this result:

                                 the url of the web page but not the source code. What do I have to do to get the source code?


                            • 11. Re: Getlayoutobjectattribute function

                                   I'll try out that step you mentioned earlier. I just saw that now.



                              • 12. Re: Getlayoutobjectattribute function

                                     The content returned by these functions should contain the HTML text of the URL's web page…nothing more.

                                For example, this is part of the HTML from the forum page you are looking at now which I got using Insert from URL just now:


                                     <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

                                     <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">


                                     <title>Getlayoutobjectattribute function . Using FileMaker Pro . Forum . FileMaker Forums</title>

                                     <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />

                                     <meta http-equiv="Content-Language" content="en" />

                                     <meta http-equiv="imagetoolbar" content="no" />

                                     <meta name="robots" content="ALL" />

                                     <meta name="author" content="FileMaker Forums,Peter Montague" />

                                     <meta name="description" content="" />

                                     <link rel="icon" href="/communities/filemaker/favicon.ico" type="image/x-icon" />

                                     <link rel="shortcut icon" href="/communities/filemaker/favicon.ico" type="image/x-icon" />

                                     <link rel="alternate" type="application/rss+xml" href="/hives/12f66388aa/feed" /><meta content="text/html; charset=utf-8" http-equiv="Content-Type"/> 

                                     <link href="/communities/filemaker_social/favicon.ico" rel="SHORTCUT ICON" /> 

                                     <script type="text/javascript" src="http://www.filemaker.com/site/js/jquery.js"> </script> 

                                     <!--[if IE]>

                                     <link href="http://www.filemaker.com/site/css/site_ie.css" rel="stylesheet" type="text/css"/>


                                     <!--[if lte IE 6]>

                                     <link href="http://www.filemaker.com/site/css/site_ie6.css" rel="stylesheet" type="text/css"/>



                                     <style type="text/css">

                                     .en_US, .fr_FR, .de_DE, .it_IT, .ja_JP, .es_ES, .fmSearchBox .en_US, .fmSearchBox .fr_FR, .fmSearchBox .de_DE, .fmSearchBox .it_IT, .fmSearchBox .ja_JP, .fmSearchBox .es_ES {display: none;}

                                     .rn_LoginDialog2{width: 210px;}

                                     .rn_LoginDialog2.rn_ContentLoading{background:url(/euf/rightnow/optimized/1275687771/themes/standard/images/loading.gif) no-repeat center center;}

                                     .rn_LoginDialog2 input{margin-bottom:5px;}

                                     .rn_LoginDialog2 input[type="text"], .rn_LoginDialog2 input[type="password"]{width:200px;}

                                     .rn_LoginDialog2 label{margin-bottom:5px;display:block;}

                                     .rn_LoginDialog2 div{margin-bottom: 5px;}


                                • 13. Re: Getlayoutobjectattribute function

                                       Did you enter the correct URL in the WebViewer's address or use Set Web Viewer scriptstep to set the URL?

                                  • 14. Re: Getlayoutobjectattribute function

                                         That insert from URL script step worked. Wow. And to think that I spent money on the troi url plug in before I bought FMPA 12.Thanks Jade.