12 Replies Latest reply on Dec 4, 2014 7:42 AM by philmodjunk

    Hide Object When Query

    pmehta91

      Title

      Hide Object When Query

      Post

      I have set up a portal of companies and products. A company has many different  products. I have set up a check box which states whether that product is a preferred product or not. For example, if a person searches for pens, the list of companies which sell pens come up, a button takes them to the company which is the preferred company.

      In the search results list layout, I have put text which says "preferred supplier" in red font. However, I want this to display only when the company is a preferred supplier, so in the hide option when area I inserted the formula :

      "{Product &  Brand info}::Preferred ≠ "Preferred"

      This works perfectly. However it only works on the record which is first in the portal row. If I was to have a company which sells pens and it was second in the portal, with the check box crossed, the preferred supplier in red font does not appear, 

      Hope it is not too confusing, but was wondering if anyone could help to fix this. 

        • 1. Re: Hide Object When Query
          philmodjunk

          I would guess that your Hide Object When expression is actually:

          ${Product &  Brand info}::Preferred ≠ "Preferred"

          as you would otherwise get a syntax error message. And naming a table (occurrence) to include a calculation operator (&) is not really a good idea here though it's not the subject of your post here.

          If your portal's table occurrence is named "Product & Brand info" and you put this text into the portal and not outside of it or on top of it, this should work. If you think that you have it in the portal row, I suggest entering layout mode and moving the portal a few pixels. All objects that are truly within the portal will move when you move the portal. If it's not, you need to drag this text away from the portal, release the mouse button and then drag it back, being careful to not release it until it is fully within the limits of the portal row.

          Test by moving the portal again to be sure that it moves when you move the portal.

          • 2. Re: Hide Object When Query
            pmehta91

            I have tested this and the checkbox is in the portal. As mentioned, the text only appears if the checkbox is checked for the first record in the portal, and not any other ones. 

             

            Any more suggestions?

            • 3. Re: Hide Object When Query
              pmehta91

              Just re-read what you said. I think I did not explain myself clearly. The text is not within the portal. The text is on a separate layout, on another page. 

              • 4. Re: Hide Object When Query
                philmodjunk

                And that identifies the problem. When you set up a calculation to refer to data from a related record when there are multiple related records, the calculation refers to data only from the "first" related record. The values in all other related records are ignored.

                You'll need to change something before this will work for you.

                I'd offer more help, but you have to help me before I can help you.

                Is the other layout based on the same table (occurrence) as the layout with the portal?

                If not, what table is it based on? (Check Show Records From in Layout Setup... if you are not sure.)

                 

                • 5. Re: Hide Object When Query
                  pmehta91

                  Hi Phil. Yes that was the problem, the layout wasn't based on the same table as the portal table, this issue is resolved now. 

                  However, this has come up with another issue I need resolved. Since you would probably read this I didn't want to start a new thread. The page now shows all the companies, however some companies are appearing more than once. For example, if they sell pens and pencils, and a search is made for "pen" the same company comes up in the page twice. Is there away to limit the results, that it does not show the same company twice,

                  Thanks in advance

                  • 6. Re: Hide Object When Query
                    philmodjunk

                    You'll need to describe the set up of your layout in more detail. On what table is the layout based? Is the company info from the layout's table or a related table?

                    • 7. Re: Hide Object When Query
                      pmehta91

                      The information that contains the company, and its products is in a portal, this has it's own table and layout. I also have another layout which contains company info. These two tables are related by name = name. 

                      I have created another  layout which shows the company name, email and phone address. This is the search results page. 

                      When a search is made, the search results page is listing the same company and its details more than once if the company sells more than one product that matches the search. I just want the search results page to display the company name once. 

                      • 8. Re: Hide Object When Query
                        philmodjunk

                        Sorry but that is not clear. I need to know how your tables are set up and from their which table is the basis for each layout.

                        Could you upload a screen shot of the relevant portion of Manage | Database | Relationships? And then identify which goes with each layout?

                        • 9. Re: Hide Object When Query
                          pmehta91

                          In the Search results page, it shows The Dealer Name, Email and Phone. This it is optional whether the preferred text in red shows up (As discussed above). However, the problem I am getting is that the same dealer is coming up twice if they have more than one product which is ticked as "preferred". I want the details to just appear once. Thanks. 

                          • 10. Re: Hide Object When Query
                            philmodjunk

                            On your search results page, if you enter layout setup and look at the show records from drop down. Do you see "Supplier" or "Product & Brand Info"?

                            If you see Supplier, then the only way that a Supplier can appear twice is if you have two supplier records with the same name. If you see Product & Brand Info, then this would an expected result as your layout lists Products, not suppliers and your search could easily find multiple products records from the same supplier. And you would not be able to reduce this list to one record per supplier without also hiding records from view that your search found--which would seem to defeat the purpose of your search.

                            And (new topic here), matching records by name in a relationship is not a good design choice. Company names are not unique and they change from time to time. You can also accidentally mis-enter a name and then later discover the mistake. If you later need to change a Supplier name, you will break the link to all related Product & Brand Info records unless you carefully make an identical update to all the related records. And if you have two supplier records with the same name, you will see Product & Brand records for both suppliers in the same portal. All of the issues listed in this paragraph can be avoided if you link records by an auto entered serial number field defined in the Supplier table.

                            • 11. Re: Hide Object When Query
                              pmehta91

                              Hi cheers for your matching relationships by name comment, will take it on board. 

                              In the results page, if I show records from "supplier", the hidden text only appears if the product is the first record in the portal I created.  If the record isn't in the first record of the portal and it does match the search, the hidden text does not appear, If this can be resolved it can solve my problem. Any ideas?

                              • 12. Re: Hide Object When Query
                                philmodjunk

                                I have set up a check box which states whether that product is a preferred product or not.

                                In the results page, if I show records from "supplier", the hidden text only appears if the product is the first record in the portal I created.

                                Let's take a careful look at those two sentences that I've quoted from previous posts that you've made. My immediate question is: "when you search, are you searching for products or suppliers?" This is a key question since you can have many products & brands linked to the same supplier record.

                                If you are searching for suppliers, this "preferred supplier" text makes no sense as it is specific to particular products. If this is what you are doing, you should use a layout based on Suppliers with a portal to product Info and with this conditionally formatted text placed inside the rows of the portal so that you can see which products for a given supplier have that designation. And if the "Preferred" designation should extend to all products & brands supplied by that supplier, then you need to make this designation in the Supplier table instead of Products & Brand Info.

                                If you are search for products, your layout should be based on the product and brand info table and since a given supplier can supply multiple products, you should see the same supplier listed once for each such product found via your search.