8 Replies Latest reply on Aug 7, 2012 12:58 PM by MarcMcCall

    Help getting a custom function working via a portal if posible

    MarcMcCall

      Title

      Help getting a custom function working via a portal if posible

      Post

      Hey guys,

       

      I'm trying to get this cusom function working if posible.  It is called HiliteSingle   HiliteSingle ( text ; searchString )

      Let ( [
      // TEST FOR MATCH
      pos = Position ( text ; searchString ; 1 ; 1 ) 
      ] ;
      // IF MATCH IS FOUND
      Case ( pos ;
      // BEGIN CALCULATION
      Let ( [
      textBefore = Left ( text ; pos - 1 ) ;
      len = Length ( searchString ) ;
      string = Middle ( text ; pos ; len ) ;
      textAfter = Right ( text ; Length ( text ) - pos - len + 1 ) 
      ] ;
      textBefore & TextStyleAdd ( string ; HighlightYellow ) & HiliteSingle ( textAfter ; searchString ) 
      ) ;
      // ELSE RETURN TEXT
      text )
      )

       

      It works great using it on field from the same table, however I am trying to use it via a portal.

       

      The portal is on table Contacts, and the portal is showing records from Addresses_Contacts||dove_account||

      I have the graph set up as Contacts::dove_account = Addresses::dove_account

      I have a field on the portal showing  Addresses_Contacts||dove_account||::address_description

      If it is posible I would like the use the Contacts::street1 as the searchstring for the Addresses_Contacts||dove_account||::address_description in the portal.  I have tried every configuration I can think of to no avail.

        • 1. Re: Help getting a custom function working via a portal if posible
          philmodjunk

          I assume that you are using this function call in a calculation field. The following should work:

          HiliteSingle ( address_description ; Contacts::street1 )

          Make sure that you select "Evaluate from the context of Addresses_Contacts||dove_account||" in the "context" menu at the top of specify calculation.

          • 2. Re: Help getting a custom function working via a portal if posible
            MarcMcCall

            Thanx Phil,

             

            Its getting there, but it is only Highlighting portal row serched from the first Contact Record.  The first Record in Contacts has Street1 as 2141 W. Gate Place and that is Highlighted in every Contacts Record in the Portal.

            • 3. Re: Help getting a custom function working via a portal if posible
              philmodjunk

              I get confused when I re-examine your original post.

              You indicated that you have this relationship:

              Contacts::dove_account = Addresses::dove_account

              but that your portal refers to:

              Addresses_Contacts||dove_account||

              Which is not listed in your relationship.

              Is your relationship really this?

              Addresses::dove_account = Addresses_Contacts||dove_account||::dove_account

              Is the layout on which the portal is located based on the occurrence of Addresses used in the above relationship?

              Your reference to Contacts::street1 highlighting text in Addresses_Contacts||dove_account||::address_description

              doesn't make sense here as there is no relationship specified betweeen two occurrences of contacts.

              • 4. Re: Help getting a custom function working via a portal if posible
                MarcMcCall

                My appologied Phil,

                 

                The relationship is Contacts::dove_account = Addresses_Contacts||dove_account||::doveAccount

                The portal is on Contacts.  

                Showing records from  Addresses_Contacts||dove_account||

                The field on the portal is

                Addresses_Contacts||dove_account||::address_description

                address_description is a calculation 

                HiliteSingle ( Addresses_Contact||dove_account||::address_description ; Contacts::Street1 )

                Addresses_Contacts||dove_account|| is an occurrence of Addresses

                • 5. Re: Help getting a custom function working via a portal if posible
                  philmodjunk

                  Address_description refers to itself in it's calculation making this a recursive calculation that then evaluates recursively with no end condition to stop the recursion.

                  It looks like you need two fields where you have one: Address_Description--a text field containing the address_description text or a text function that combines data to produce the text shown in it, and Highlighted_Address_Description that uses your custom function to refer to the search text and the text in Address_Description.

                  That said, this calculation would be defined in Addresses and defined to evaluate from the context of Addresses_Contacts||dove_account||

                  Which would define Highlighted_Address_Description as:

                  HiliteSingle ( address_Description ; Contacts::Street1 )

                  • 6. Re: Help getting a custom function working via a portal if posible
                    MarcMcCall

                    I have done like you suggested and its still doing the same thing.

                     

                    I created an auto field to Index the address_description   address_description2 

                    then I created another field Highlight_address_description Type:Calculation, From Addresses_Contacts||dove_account||, = HiliteSingle (address_description2 ; Contacts::Street1 )

                     

                    • 7. Re: Help getting a custom function working via a portal if posible
                      philmodjunk

                      I've been playing with a demo file figuring to share it with you and think I have spotted the problem.

                      This is a self join relationship, so if you have 4 or 5 records with the same value in dove_account, any one of them could be the current record when you examine the list of records in the portal, but when you refer to field from a related table, such as your street 1 field, all the records will refer back to the first related record and thus this funciton highlights according to the text in the Streat1 field regardless of which record is current.

                      To get the results you want will take some changes.

                      The simplest is to use a field with global storage in place of street1, but I am guessing you want the text to highlight by the current text in street1 without the user needing to enter or edit the text in that field and that this text should be different on every record.

                      Use this expression instead of the current call:

                      HiliteSingle ( address_Description ; $$Street )

                      Then use the onRecordLoad script trigger to perform this script:

                      Set Variable [$$Street ; value: Contacts::Street1]

                      If you don't see things highlight correctly, add a refresh window step after the set field step.

                      This assumes that you are browsing these records on a form view layout.

                      • 8. Re: Help getting a custom function working via a portal if posible
                        MarcMcCall

                        That works great... Thanks Phil.