1 2 Previous Next 17 Replies Latest reply on Jun 18, 2013 6:59 AM by philmodjunk

    Embedding Sortable List View within a Form View Layout

    JerryAPowers

      Title

      Embedding Sortable List View within a Form View Layout

      Post

           Can anyone point me in the right direction for embedding a sortable list view within a Form View Layout? What I am attempting is to have a list of 25 comparable properties in the list view that can be sorted by any of the fields while I have a form above containing the parameters for determining the rating of appropriate comparable properties. The users my want to sort the list by proximity to the subject property, sales price, etc. In the end, I need the best 4 comparable properties to be at the top of the list. Obviously, that part is simple since I will have a score that ranks the comparable properties.

           Thank you,

           Jerry A Powers

        • 2. Re: Embedding Sortable List View within a Form View Layout
          JerryAPowers

               Rick,

               That is what I was thinking. Since I want the 25 comparable properties to be in the sortable List view, I'm assuming that I need to store the comparable property data in a different table and establish a relationship? Additionally, I believe that I need to create repeating fields instead of 25 sets of comparable property data fields?

               Is this what you were thinking?

                

          • 3. Re: Embedding Sortable List View within a Form View Layout
            schamblee

                 You don't give enough details to state that you need another table for your comparable property data.  You can have a self join relationship.  Repeating fields are not really used any more, it's old technology, before relational databases.  Repeating fields are harder to deal with and more difficult to create reports from than if you just used another table with a relationship to the parent table.  I wouldn't use repeating fields.

            • 4. Re: Embedding Sortable List View within a Form View Layout
              philmodjunk

                   Note also that with the same relationship that makes a portal work, you can set up a layout based on the portal's table occurrence that is in List View with the fields you want in your form view and out side of the portal placed in the header. While this has a bit of a different look to it, it can make sorting the records listed below the header much easier to do.

              • 5. Re: Embedding Sortable List View within a Form View Layout
                JerryAPowers

                     I have my Comps data in a separate table and I have successfully setup a Portal that displays the Comps. However, I did this by defining the comps fields as repeating - I know, VERY BAD! However, upon searching, I cannot determine exactly how to get this to work without repeating fields. From what I read, it appears that if I add records to a portal they will automatically be related to the record in the other table - this seems simple enough. However, what I have is that I am retrieving comps information over the internet and extracting the XML data to parse the data into the comps fields.

                     I really need a sortable list for the comps and a portal appears to be the perfect solution. However, if I change the comp fields to no longer be repeating fields, how is filemaker going to relate up to 25 comps with 1 subject property record when it is extracting the information?

                     I previously had sets of 25 comps data fields defined, however, that prevented me from placing them into a sortable list.

                     For clarity, I have attached an image of a portion of the script that extracts the comps data.

                     Thank you for any help!

                      

                • 6. Re: Embedding Sortable List View within a Form View Layout
                  JerryAPowers

                       This may be answering some of my own question - instead of extracting the data into a field, would I extract it directly into a portal row? I need to research how this can be done.

                  • 7. Re: Embedding Sortable List View within a Form View Layout
                    philmodjunk

                         The data should be extracted into a new record in a related table. While a portal could be used for that, it's not the only way and probably not the best way. Are you importing the xml data or parsing it?

                    • 8. Re: Embedding Sortable List View within a Form View Layout
                      JerryAPowers

                           Phil,

                           Thank you for your response. To extract the data into a new record in a related table would require creating 25 new records for each related "subject property" from the parent table. I'm not sure how filemaker would know that each of those 25 new records were related to the "subject property" - can you enlighten me on how to do this without extracting them directly into the named portal? I'm very interested in utilzing the best performance solution.

                           I am both importing and parsing the xml data. My script first imports it into 1 field and then parses the 25 comps into their respective fields. Probably not the cleanest way, but I set up it so that I could verify that I retrieved the xml information. I should combine them into 1 step so that I can keep the database size down since the way that I am doing this essentially creates duplicate information.

                      • 9. Re: Embedding Sortable List View within a Form View Layout
                        philmodjunk

                             There are many ways to link newly created child records to the current parent record. It does not require that a script interact directly with a portal object on a layout--which can get complicated and produces a solution that is a bit "brittle"--easily broken by future edits to the layout if the developer is not careful.

                             The method that works best for you will depend on what you have in place at the time you do it. If you are on a Parent record and need to parse out data in the parent table's field into a number of related child records, you might do it this way (Substitute your field and table occurrence names for mine):

                        Set Variable [$ID ; value: ParentTable::PrimaryKey ]
                             Set variable [$CompValue ; //Your calc for parsing a comp value here ]
                             Go to Layout ["Child Table" (Child Table) ]
                             New Record/Request
                        Set field [Child::ForeignKey ; $ID ]
                             Set Field [Child::Comp ; $CompValue]
                             Go to Layout [Original Layout]

                             The steps shown in blue are what link the new related child record to the current parent record. And steps 2 through 7 can be placed inside a loop such that your script parses a single comp value and puts it in a new record with each pass through the loop. (An exit loop step would also be needed to exit the loop after the last Comp value is parsed.)

                             This is not the only way, and if the right data exists in your xml data, you may be able to set up a "grammar" and separate import of the same data that automatically imports the comp data into different records and links them to the correct parent record, but this assumes that there is xml data that can be used to establish that link.

                        • 10. Re: Embedding Sortable List View within a Form View Layout
                          JerryAPowers

                               Phil -

                               You are the MAN!! Your solution worked perfectly! It took me some time to understand exactly what your script was doing and how I needed to customize it for my exact use, but I finally got it. Because I am extracting 10 Comp fields from the XML data I chose not to define each as variables - it appears that it adds an additional line to the script. I have included a screen image of my completed script. Is defining the Set Field calculations as variables a better solution for some reason?

                               Again, thank you very much! This solution also appears to have solved my problem with my Average Valuation calculation that was extremely long and causing other problems.

                                

                          • 11. Re: Embedding Sortable List View within a Form View Layout
                            JerryAPowers

                                 I seem to be having a problem with this script now. When I was testing out this script I was testing with only 1 parent record - everything worked perfectly. However, now that I am attempting to populate the Comps data for other parent records (Subject Properties), the script is stalling at the "New Record/Request" step when attempting to create a new record in the Child Table (Comps). I thought that it could be a relationship problem between the Parent and Child tables but that doesn't make sense since the portal records to appear on the first property tested.

                                 I manually created a record within the Child table and tried the script and it ran. Therefore, it appears that even though there is a step in the script to create a new record in the Child table, it is not working even though the relationship between the two tables appear to be correct.

                                 Does anyone have any ideas how to fix this?

                                 Thank you!

                            • 12. Re: Embedding Sortable List View within a Form View Layout
                              philmodjunk

                                   I suggest that you post your script as I can think of several different ways that your script might be going wrong.

                                   To post a script to the forum:

                                     
                              1.           You can upload a screen shot of your script by using the Upload an Image controls located just below Post A Answer.
                              2.      
                              3.           You can print a script to a PDF, open the PDF and then select and copy the script as text from the opened PDF to your clipboard for pasting here.
                              4.      
                              5.           If You have FileMaker Advanced, you can generate a database design report and copy the script as text from there.
                              6.      
                              7.           If you paste a text form of the script, you can use the Script Pretty box in the Known Bugs List database to paste a version that is single spaced and indented for a more professional and easier to read format.
                              • 13. Re: Embedding Sortable List View within a Form View Layout
                                JerryAPowers

                                     Phil,

                                     I thought that I had solved the problem in thinking that my file was corrupted. Therefore, I manually re-created my Comps table, fields, and the above script. However, I found that the script will run perfectly when there are no other properties residing in the Comps (child table). Once I have any other records in that table, a new subject property from the Parent table will result in the script stalling at the Create New Record step.

                                     I tried figuring out your ScriptPretty utility but I could find a place to paste my script. Therefore, I am forced to paste the text manually - sorry about that!

                                       
                                •           Set Web Viewer [ Object Name: "ZillowWebViewer"; URL: "http://www.zillow.com/webservice/GetDeepSearchResults.htm?zws-id=" & Defaults::ZWSID & "&address=" & Substitute(Property Analyzer::Address; " "; "+") & "&citystatezip=" & Property Analyzer::City & "%2C+" & Property Analyzer::State & Property Analyzer::Z… ]
                                •      
                                •           Set Variable [ $timeout; Value:60 ]
                                •      
                                •           Set Variable [ $startTime; Value:Get ( CurrentTimeStamp ) ]
                                •      
                                •           Loop
                                •      
                                •           Set Variable [ $content; Value:GetLayoutObjectAttribute ( "ZillowWebViewer" ; "content" ) ]
                                •      
                                •           Exit Loop If [ Get ( CurrentTime ) > $startTime + $timeout or not IsEmpty (GetLayoutObjectAttribute ( "ZillowWebViewer" ; "content" ) ) ]
                                •      
                                •           End Loop
                                •      
                                •           Set Field [ Property Analyzer::Zillow API Content; Let ( _contentWebViewer = GetLayoutObjectAttribute ( "ZillowWebViewer" ; "content" ) ; GetRealXMLFromWebViewer ( _contentWebViewer) ) ]
                                •      
                                •           Set Field [ Property Analyzer::ZillowCode; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Content ; "code" ; "code" ; 1 )) ]
                                •      
                                •           Set Field [ Property Analyzer::ZPID; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Content ; "ZPID" ; "ZPID" ; 1 )) ]
                                •      
                                •           Set Field [ Property Analyzer::Zillow Valuation; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Content ; "amount currency=" ; "</amount" ; 1 )) ]
                                •      
                                •           Set Field [ Property Analyzer::Latitude; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Content ; "latitude" ; "latitude" ; 1 )) ]
                                •      
                                •           Set Field [ Property Analyzer::Longitude; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Content ; "longitude" ; "longitude" ; 1 )) ]
                                •      
                                •           Set Field [ Property Analyzer::Number Bedrooms; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Content ; "bedrooms" ; "bedrooms" ; 1 )) ]
                                •      
                                •           Set Field [ Property Analyzer::Number Baths; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Content ; "bathrooms" ; "bathrooms" ; 1 )) ]
                                •      
                                •           Set Field [ Property Analyzer::Square Footage; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Content ; "finishedSqft" ; "finishedSqft" ; 1 )) ]
                                •      
                                •           Set Field [ Property Analyzer::Year Built; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Content ; "yearbuilt" ; "yearbuilt" ; 1 )) ]
                                •      
                                •           Set Field [ Property Analyzer::First Mortgage Origination Date; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Content ; "lastSoldDate>" ; "</lastSoldDate" ; 1 )) ]
                                •      
                                •           Set Field [ Property Analyzer::First Mortgage Amount; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Content ; "lastSoldPrice" ; "lastSoldPrice" ; 1 )) ]
                                •      
                                •           Set Web Viewer [ Object Name: "ZillowWebViewer"; URL: "" ]
                                •      
                                •           Set Field [ Property Analyzer::ZillowCode; "" ]
                                •      
                                •           Set Web Viewer [ Object Name: "ZillowWebViewer"; URL: "http://www.zillow.com/webservice/GetUpdatedPropertyDetails.htm?zws-id="&Defaults::ZWSID&"&zpid="&Property Analyzer::ZPID&"" ]
                                •      
                                •           Set Variable [ $timeout; Value:60 ]
                                •      
                                •           Set Variable [ $startTime; Value:Get ( CurrentTimeStamp ) ]
                                •      
                                •           Loop
                                •      
                                •           Set Variable [ $content; Value:GetLayoutObjectAttribute ( "ZillowWebViewer" ; "content" ) ]
                                •      
                                •           Exit Loop If [ Get ( CurrentTime ) > $startTime + $timeout or not IsEmpty (GetLayoutObjectAttribute ( "ZillowWebViewer" ; "content" ) ) ]
                                •      
                                •           End Loop
                                •      
                                •           Set Field [ Property Analyzer::Zillow API Prop Content; Let ( _contentWebViewer = GetLayoutObjectAttribute ( "ZillowWebViewer" ; "content" ) ; GetRealXMLFromWebViewer ( _contentWebViewer) ) ]
                                •      
                                •           Set Field [ Property Analyzer::ZillowCode; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Prop Content ; "code" ; "code" ; 1 )) ]
                                •      
                                •           If [ CountWordOccurrences ( Property Analyzer::Zillow API Prop Content ; "numfloors" ) > 0 and CountWordOccurrences ( Property Analyzer::Zillow API Prop Content ; "coveredparkingspaces" ) > 0 ]
                                •      
                                •           Set Field [ Property Analyzer::Levels; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Prop Content ; "numfloors" ; "numfloors" ; 1 )) ]
                                •      
                                •           Set Field [ Property Analyzer::Garage Bays; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Prop Content ; "coveredparkingspaces" ; "coveredparkingspaces" ; 1 )) ]
                                •      
                                •           Set Field [ Property Analyzer::Number Bedrooms; GetAsNumber ( ParseData (Property Analyzer::Zillow API Prop Content ; "bedrooms" ; "bedrooms" ; 1 ) ) ]
                                •      
                                •           Set Field [ Property Analyzer::Number Baths; GetAsNumber ( ParseData (Property Analyzer::Zillow API Prop Content ; "bathrooms" ; "bathrooms" ; 1 ) ) ]
                                •      
                                •           Set Field [ Property Analyzer::Square Footage; GetAsNumber ( ParseData (Property Analyzer::Zillow API Prop Content ; "finishedSqft" ; "finishedSqft" ; 1 ) ) ]
                                •      
                                •           Set Field [ Property Analyzer::Lot Area; GetAsNumber ( ParseData (Property Analyzer::Zillow API Prop Content ; "lotsizeSqft" ; "lotsizeSqft" ; 1 ) ) ]
                                •      
                                •           Set Field [ Property Analyzer::Year Built; GetAsNumber ( ParseData (Property Analyzer::Zillow API Prop Content ; "yearbuilt" ; "yearbuilt" ; 1 ) ) ]
                                •      
                                •           End If
                                •      
                                •           Set Field [ Property Analyzer::ZillowCode; "" ]
                                •      
                                •           Set Web Viewer [ Object Name: "ZillowWebViewer"; URL: "" ]
                                •      
                                •           Set Web Viewer [ Object Name: "ZillowWebViewer"; URL: "http://www.zillow.com/webservice/GetDeepComps.htm?zws-id="&Defaults::ZWSID&"&zpid="&Property Analyzer::ZPID&"&count=25" ]
                                •      
                                •           Set Variable [ $timeout; Value:60 ]
                                •      
                                •           Set Variable [ $startTime; Value:Get ( CurrentTimeStamp ) ]
                                •      
                                •           Loop
                                •      
                                •           Set Variable [ $content; Value:GetLayoutObjectAttribute ( "ZillowWebViewer" ; "content" ) ]
                                •      
                                •           Exit Loop If [ Get ( CurrentTime ) > $startTime + $timeout or not IsEmpty (GetLayoutObjectAttribute ( "ZillowWebViewer" ; "content" ) ) ]
                                •      
                                •           End Loop
                                •      
                                •           Set Field [ Property Analyzer::Zillow API Comps; Let ( _contentWebViewer = GetLayoutObjectAttribute ( "ZillowWebViewer" ; "content" ) ; GetRealXMLFromWebViewer ( _contentWebViewer) ) ]
                                •      
                                •           Set Field [ Property Analyzer::ZillowCode; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Comps ; "code" ; "code" ; 1 )) ]
                                •      
                                •           Set Field [ Property Analyzer::Lot Area; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Comps ; "lotsizeSqft>" ; "</lotsizeSqft" ; 1 )) ]
                                •      
                                •           Set Variable [ $ID; Value:Property Analyzer::ID ]
                                •      
                                •           Show All Records
                                •      
                                •           Set Field [ Property Analyzer::Comps_Count; 1 ]
                                •      
                                •           Go to Layout [ “Comp2” (Comps) ]
                                •      
                                •           Loop
                                •      
                                •           Exit Loop If [ Property Analyzer::Comps_Count = 26 ]
                                •      
                                •           Go to Layout [ “Comp2” (Comps) ]
                                •      
                                •           New Record/Request
                                •      
                                •           Set Field [ Comps::PropertyIdFk; $ID ]
                                •      
                                •           Set Field [ Comps::API; GetAsText ( ParseData ( Property Analyzer::Zillow API Comps ; "<comp score" ; "</comp>" ; Property Analyzer::Comps_Count ) ) ]
                                •      
                                •           If [ CountWordOccurrences ( Comps::API ; "bedrooms" ) > 0 and CountWordOccurrences ( Comps::API ; "bathrooms" ) > 0 and CountWordOccurrences ( Comps::API ; "yearbuilt" ) > 0 and CountWordOccurrences ( Comps::API ; "lotsizesqft" ) > 0 and CountWordOccurrences ( Comps::API ; "finishedsqft" ) > 0 and CountWordOccurrences ( Comps::API ; "lastsolddate" ) > 0 and CountWordOccurrences ( Comps::API ; "lastsoldprice" ) > 0 ]
                                •      
                                •           Set Field [ Comps::Address; GetAsText ( ParseData ( Comps::API ; "street>" ; "</street" ; 1 ) ) ]
                                •      
                                •           Set Field [ Comps::Beds; GetAsNumber ( ParseData ( Comps::API ; "bedrooms>" ; "</bedrooms" ; 1 ) ) ]
                                •      
                                •           Set Field [ Comps::Baths; GetAsNumber ( ParseData ( Comps::API ; "bathrooms>" ; "</bathrooms" ; 1 ) ) ]
                                •      
                                •           Set Field [ Comps::Square Footage; GetAsNumber ( ParseData ( Comps::API ; "finishedSqft>" ; "</finishedSqft" ; 1 ) ) ]
                                •      
                                •           Set Field [ Comps::Lot Area; GetAsNumber ( ParseData ( Comps::API ; "lotsizeSqft>" ; "</lotsizeSqft" ; 1 ) ) ]
                                •      
                                •           Set Field [ Comps::Year Built; GetAsNumber ( ParseData ( Comps::API ; "yearbuilt>" ; "</yearbuilt" ; 1 ) ) ]
                                •      
                                •           Set Field [ Comps::Latitude; GetAsNumber ( ParseData ( Comps::API ; "latitude>" ; "</latitude" ; 1 ) ) ]
                                •      
                                •           Set Field [ Comps::Longitude; GetAsNumber ( ParseData ( Comps::API ; "longitude>" ; "</longitude" ; 1 ) ) ]
                                •      
                                •           Set Field [ Comps::Sale Date; GetAsDate ( ParseData ( Comps::API ; "lastSoldDate>" ; "</lastSoldDate" ; 1 ) ) ]
                                •      
                                •           Set Field [ Comps::Purchase Price; GetAsNumber ( ParseData ( Comps::API ; "lastSoldPrice" ; "</lastSoldPrice" ; 1 ) ) ]
                                •      
                                •           If [ Comps::Score ≥ Property Analyzer::Comp Min Score ]
                                •      
                                •           Set Field [ Comps::Select; "Yes" ]
                                •      
                                •           End If
                                •      
                                •           Else
                                •      
                                •           Delete Record/Request [ No dialog ]
                                •      
                                •           Commit Records/Requests
                                •      
                                •           End If
                                •      
                                •           Set Field [ Property Analyzer::Comps_Count; Property Analyzer::Comps_Count + 1 ]
                                •      
                                •           End Loop
                                •      
                                •           Go to Layout [ original layout ]
                                •      
                                •           Set Field [ Property Analyzer::Comps in ARV; "Yes" ]

                                     By the way, I am currently using FileMaker Pro 10 Advanced on a Windows 7 computer. I hope to upgrade to 12 soon!

                                      

                                     Thank you!

                                • 14. Re: Embedding Sortable List View within a Form View Layout
                                  philmodjunk

                                       Script pretty is a tab in the bug report layout--not a logical place for it, but haven't taken the time to change the design. You paste the text into the field on that tab and the text automatically reformats so that you can paste it here. That's what I did here and I added comment steps as I figured out the intent of each section of this script. Please note questions an observations in red. It appears that you are referring to fields in the Property Analyzer table from the comps2 layout under circumstances where you might be linking to the wrong record in Property Analyzer. The step where you delete a record may also create issues. You might solve some problems by setting a value in a field in comps to mark that record for deletion, then don't delete it until the script is finished. THen you can perform a find for all such marked records and delete them all in one delete all records step.

                                  #Extract Content from Web Viewer
                                       Set Web Viewer [ Object Name: "ZillowWebViewer"; URL: "http://www.zillow.com/webservice/GetDeepSearchResults.htm?zws-id=" & Defaults::ZWSID & "&address=" & Substitute(Property Analyzer::Address; " "; "+") & "&citystatezip=" & Property Analyzer::City & "%2C+" & Property Analyzer::State & Property Analyzer::Z… ]
                                       Set Variable [ $timeout; Value:60 ]
                                       Set Variable [ $startTime; Value:Get ( CurrentTimeStamp ) ]
                                       Loop
                                           Set Variable [ $content; Value:GetLayoutObjectAttribute ( "ZillowWebViewer" ; "content" ) ]
                                           Exit Loop If [ Get ( CurrentTime ) > $startTime + $timeout or not IsEmpty (GetLayoutObjectAttribute ( "ZillowWebViewer" ; "content" ) ) ]
                                       End Loop
                                  #Put content of web viewer into field of current record in Property Analyzer
                                       Set Field [ Property Analyzer::Zillow API Content; Let ( _contentWebViewer = GetLayoutObjectAttribute ( "ZillowWebViewer" ; "content" ) ;
                                                                                                                                      GetRealXMLFromWebViewer ( _contentWebViewer) ) ]
                                  #parse content into individual fields
                                       Set Field [ Property Analyzer::ZillowCode; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Content ; "code" ; "code" ; 1 )) ]
                                       Set Field [ Property Analyzer::ZPID; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Content ; "ZPID" ; "ZPID" ; 1 )) ]
                                       Set Field [ Property Analyzer::Zillow Valuation; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Content ; "amount currency=" ; "</amount" ; 1 )) ]
                                       Set Field [ Property Analyzer::Latitude; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Content ; "latitude" ; "latitude" ; 1 )) ]
                                       Set Field [ Property Analyzer::Longitude; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Content ; "longitude" ; "longitude" ; 1 )) ]
                                       Set Field [ Property Analyzer::Number Bedrooms; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Content ; "bedrooms" ; "bedrooms" ; 1 )) ]
                                       Set Field [ Property Analyzer::Number Baths; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Content ; "bathrooms" ; "bathrooms" ; 1 )) ]
                                       Set Field [ Property Analyzer::Square Footage; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Content ; "finishedSqft" ; "finishedSqft" ; 1 )) ]
                                       Set Field [ Property Analyzer::Year Built; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Content ; "yearbuilt" ; "yearbuilt" ; 1 )) ]
                                       Set Field [ Property Analyzer::First Mortgage Origination Date; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Content ; "lastSoldDate>" ; "</lastSoldDate" ; 1 )) ]
                                       Set Field [ Property Analyzer::First Mortgage Amount; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Content ; "lastSoldPrice" ; "lastSoldPrice" ; 1 )) ]
                                  #Set Web Viewer to different URL
                                       Set Web Viewer [ Object Name: "ZillowWebViewer"; URL: "" ]
                                       Set Field [ Property Analyzer::ZillowCode; "" ]
                                       Set Web Viewer [ Object Name: "ZillowWebViewer"; URL: "http://www.zillow.com/webservice/GetUpdatedPropertyDetails.htm?zws-id="&Defaults::ZWSID&"&zpid="&Property Analyzer::ZPID&"" ]
                                       Set Variable [ $timeout; Value:60 ]
                                       Set Variable [ $startTime; Value:Get ( CurrentTimeStamp ) ]
                                       Loop
                                           Set Variable [ $content; Value:GetLayoutObjectAttribute ( "ZillowWebViewer" ; "content" ) ]
                                           Exit Loop If [ Get ( CurrentTime ) > $startTime + $timeout or not IsEmpty (GetLayoutObjectAttribute ( "ZillowWebViewer" ; "content" ) ) ]
                                       End Loop
                                  #More parsing of data from web viewer
                                       Set Field [ Property Analyzer::Zillow API Prop Content; Let ( _contentWebViewer = GetLayoutObjectAttribute ( "ZillowWebViewer" ; "content" ) ;
                                                                                                                                                 GetRealXMLFromWebViewer ( _contentWebViewer) ) ]
                                       Set Field [ Property Analyzer::ZillowCode; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Prop Content ; "code" ; "code" ; 1 )) ]
                                       If [ CountWordOccurrences ( Property Analyzer::Zillow API Prop Content ; "numfloors" ) > 0 and
                                            CountWordOccurrences ( Property Analyzer::Zillow API Prop Content ; "coveredparkingspaces" ) > 0 ]
                                           Set Field [ Property Analyzer::Levels; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Prop Content ; "numfloors" ; "numfloors" ; 1 )) ]
                                           Set Field [ Property Analyzer::Garage Bays; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Prop Content ; "coveredparkingspaces" ;
                                                                                                                         "coveredparkingspaces" ; 1 )) ]
                                           Set Field [ Property Analyzer::Number Bedrooms; GetAsNumber ( ParseData (Property Analyzer::Zillow API Prop Content ; "bedrooms" ;
                                                                                                                                     "bedrooms" ; 1 ) ) ]
                                           Set Field [ Property Analyzer::Number Baths; GetAsNumber ( ParseData (Property Analyzer::Zillow API Prop Content ; "bathrooms" ;
                                                                                                                            "bathrooms" ; 1 ) ) ]
                                           Set Field [ Property Analyzer::Square Footage; GetAsNumber ( ParseData (Property Analyzer::Zillow API Prop Content ;
                                                                                                                               "finishedSqft" ; "finishedSqft" ; 1 ) ) ]
                                           Set Field [ Property Analyzer::Lot Area; GetAsNumber ( ParseData (Property Analyzer::Zillow API Prop Content ; "lotsizeSqft" ; "lotsizeSqft" ; 1 ) ) ]
                                           Set Field [ Property Analyzer::Year Built; GetAsNumber ( ParseData (Property Analyzer::Zillow API Prop Content ; "yearbuilt" ; "yearbuilt" ; 1 ) ) ]
                                       End If
                                  #Set Web Viewer to yet another URL
                                       Set Field [ Property Analyzer::ZillowCode; "" ]
                                       Set Web Viewer [ Object Name: "ZillowWebViewer"; URL: "" ]
                                       Set Web Viewer [ Object Name: "ZillowWebViewer"; URL: "http://www.zillow.com/webservice/GetDeepComps.htm?zws-id="&Defaults::ZWSID&"&zpid="&Property Analyzer::ZPID&"&count=25" ]
                                       Set Variable [ $timeout; Value:60 ]
                                       Set Variable [ $startTime; Value:Get ( CurrentTimeStamp ) ]
                                       Loop
                                           Set Variable [ $content; Value:GetLayoutObjectAttribute ( "ZillowWebViewer" ; "content" ) ]
                                           Exit Loop If [ Get ( CurrentTime ) > $startTime + $timeout or not IsEmpty (GetLayoutObjectAttribute ( "ZillowWebViewer" ; "content" ) ) ]
                                       End Loop
                                  #Parse the Data
                                       Set Field [ Property Analyzer::Zillow API Comps; Let ( _contentWebViewer = GetLayoutObjectAttribute ( "ZillowWebViewer" ; "content" ) ;
                                                                                                                              GetRealXMLFromWebViewer ( _contentWebViewer) ) ]
                                       Set Field [ Property Analyzer::ZillowCode; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Comps ; "code" ; "code" ; 1 )) ]
                                       Set Field [ Property Analyzer::Lot Area; GetAsNumber ( ParseData ( Property Analyzer::Zillow API Comps ; "lotsizeSqft>" ; "</lotsizeSqft" ; 1 )) ]
                                       Set Variable [ $ID; Value:Property Analyzer::ID ]
                                  #Why Show all records?  Still on same current record...
                                       Show All Records
                                       Set Field [ Property Analyzer::Comps_Count; 1 ]
                                  #Is there a relationship linking Comps to Property Analyzer?
                                       Go to Layout [ “Comp2” (Comps) ]
                                       Loop
                                           Exit Loop If [ Property Analyzer::Comps_Count = 26 ]--> you aren't on the property anlyzer layout anymore, this step may very well fail as a result
                                           Go to Layout [ “Comp2” (Comps) ]--You never leave "Comp2" inside this loop so this step does nothing
                                           New Record/Request
                                           Set Field [ Comps::PropertyIdFk; $ID ]-->only now can you be sure that Comps can be linked to Property analyzer
                                           Set Field [ Comps::API; GetAsText ( ParseData ( Property Analyzer::Zillow API Comps ; "<comp score" ; "</comp>" ;
                                                                                      Property Analyzer::Comps_Count ) ) ]
                                           If [ CountWordOccurrences ( Comps::API ; "bedrooms" ) > 0 and
                                                CountWordOccurrences ( Comps::API ; "bathrooms" ) > 0 and
                                                CountWordOccurrences ( Comps::API ; "yearbuilt" ) > 0 and
                                                CountWordOccurrences ( Comps::API ; "lotsizesqft" ) > 0 and
                                                CountWordOccurrences ( Comps::API ; "finishedsqft" ) > 0 and
                                                CountWordOccurrences ( Comps::API ; "lastsolddate" ) > 0 and
                                                CountWordOccurrences ( Comps::API ; "lastsoldprice" ) > 0 ]
                                          #Parse data but only if all of the listed keywords are present in Comps::API
                                               Set Field [ Comps::Address; GetAsText ( ParseData ( Comps::API ; "street>" ; "</street" ; 1 ) ) ]
                                               Set Field [ Comps::Beds; GetAsNumber ( ParseData ( Comps::API ; "bedrooms>" ; "</bedrooms" ; 1 ) ) ]
                                               Set Field [ Comps::Baths; GetAsNumber ( ParseData ( Comps::API ; "bathrooms>" ; "</bathrooms" ; 1 ) ) ]
                                               Set Field [ Comps::Square Footage; GetAsNumber ( ParseData ( Comps::API ; "finishedSqft>" ; "</finishedSqft" ; 1 ) ) ]
                                               Set Field [ Comps::Lot Area; GetAsNumber ( ParseData ( Comps::API ; "lotsizeSqft>" ; "</lotsizeSqft" ; 1 ) ) ]
                                               Set Field [ Comps::Year Built; GetAsNumber ( ParseData ( Comps::API ; "yearbuilt>" ; "</yearbuilt" ; 1 ) ) ]
                                               Set Field [ Comps::Latitude; GetAsNumber ( ParseData ( Comps::API ; "latitude>" ; "</latitude" ; 1 ) ) ]
                                               Set Field [ Comps::Longitude; GetAsNumber ( ParseData ( Comps::API ; "longitude>" ; "</longitude" ; 1 ) ) ]
                                               Set Field [ Comps::Sale Date; GetAsDate ( ParseData ( Comps::API ; "lastSoldDate>" ; "</lastSoldDate" ; 1 ) ) ]
                                               Set Field [ Comps::Purchase Price; GetAsNumber ( ParseData ( Comps::API ; "lastSoldPrice" ; "</lastSoldPrice" ; 1 ) ) ]
                                               If [ Comps::Score ≥ Property Analyzer::Comp Min Score ]
                                                   Set Field [ Comps::Select; "Yes" ]
                                               End If
                                           Else
                                          #If even one of the listed records is not in the API field, delete the record instead of parsing data
                                               Delete Record/Request [ No dialog ]
                                               Commit Records/Requests
                                           End If
                                      #If you deleted the record you are back on a record that existed before this script ran and it may or may not link to the correct
                                           #record in Property Analyzer

                                           Set Field [ Property Analyzer::Comps_Count; Property Analyzer::Comps_Count + 1 ]
                                       End Loop
                                       Go to Layout [ original layout ]
                                       Set Field [ Property Analyzer::Comps in ARV; "Yes" ]
                                        

                                  1 2 Previous Next