1 2 Previous Next 17 Replies Latest reply on Dec 16, 2014 3:19 PM by philmodjunk

    Use GetField to specify Filter Criteria

    JamesPeragine

      Title

      Use GetField to specify Filter Criteria

      Post

      I have 6 portals on my layout and I'm filtering each one a little differently, however, some of the criteria are similar.

      Instead of listing the same criteria on each filter can I create a settings field and use GetField ("settingfield") for certain criteria?  I've tried it but it doesn't seem to be working.   

      In other works, instead of putting

      Case (
      LeadsPortal::AreaCodeFilter = "SHOW ALL"; 1;
      LeadsPortal::AreaCodeFilter ="Eastern"; LeadsPortal::Timezone = "Eastern" or LeadsPortal::Timezone = "Eastern/Central";
      LeadsPortal::AreaCodeFilter ="Central"; LeadsPortal::Timezone = "Central" or LeadsPortal::Timezone = "Central/Mountain";
      LeadsPortal::AreaCodeFilter ="Mountain"; LeadsPortal::Timezone = "Mountain" or LeadsPortal::Timezone = "Mountain/Pacific";
      LeadsPortal::AreaCodeFilter ="Pacific"; LeadsPortal::Timezone = "Pacific" or LeadsPortal::Timezone = "Mountain/Pacific";
      )

      I'd like to put this calculation in a global settings field and use GetField () as on of the filter criteria for my portal.  Is this possible and/or am I doing it wrong?

        • 1. Re: Use GetField to specify Filter Criteria
          JamesPeragine

          I hope this is possible... can't get it to work.  If not is there another way to centralize snippets of code that are repeated?

          • 2. Re: Use GetField to specify Filter Criteria
            philmodjunk

            I don't understand how you are trying to use GetField for this. All of your expressions reference the value of the same two fields so I don't see how GetField would be used.

            GetFIeld allows you to refer to the value of a field indirectly. GetField ("YourTable::YourField" ) will return the value of YourTable::YourField. In place of literal text, you can use a text field that stores the tableOccurrence::FieldName text or it can refer to a variable or to a calculation that returns a text result in this format.

            • 3. Re: Use GetField to specify Filter Criteria
              JamesPeragine

              I'm not sure that I understand your answer.  

              In my Portal filter I want to use the contents of one of my fields as the filter specification, so instead of having 

              Case (
              LeadsPortal::AreaCodeFilter = "SHOW ALL"; 1;
              LeadsPortal::AreaCodeFilter ="Eastern"; LeadsPortal::Timezone = "Eastern" or LeadsPortal::Timezone = "Eastern/Central";
              LeadsPortal::AreaCodeFilter ="Central"; LeadsPortal::Timezone = "Central" or LeadsPortal::Timezone = "Central/Mountain";
              LeadsPortal::AreaCodeFilter ="Mountain"; LeadsPortal::Timezone = "Mountain" or LeadsPortal::Timezone = "Mountain/Pacific";
              LeadsPortal::AreaCodeFilter ="Pacific"; LeadsPortal::Timezone = "Pacific" or LeadsPortal::Timezone = "Mountain/Pacific";
              )

              In my portal filter, I want to have it in my field "SettingsField" and then just put

              GetField ("SettingsField")  --- [this is the field that will store the calculation above] into my portal filter criteria instead.

              This way if I have to make a change to the calculation I don't have to change it on every portal that its on.  Does this make sense?

              • 4. Re: Use GetField to specify Filter Criteria
                philmodjunk

                But it would need to be GetField ( "TableOccurrence::SettingsField") not just GetFIeld ( "SettingsField" )

                But you don't need the GetField function to do what you describe. You can just use:

                TableOccurrence::SettingsField

                as your portal filter expression and you'll get the same result and not need the added complication of using Get Field.

                Make sure to select "Number" as your calculation field's result type, BTW.

                • 5. Re: Use GetField to specify Filter Criteria
                  JamesPeragine

                  hmmm I copied my filter criteria into a calculation field and set it to number (so that it would be boolean) but that's not working.  

                  • 6. Re: Use GetField to specify Filter Criteria
                    JamesPeragine

                    and of coarse i put that calculation field as my new filter criteria. 

                    • 7. Re: Use GetField to specify Filter Criteria
                      JamesPeragine

                      Also I was using the table and the field in the GetField Function, however, I still can't get it to work.

                       

                      • 8. Re: Use GetField to specify Filter Criteria
                        JamesPeragine

                        This is what I have in my Filter Criteria

                         

                        GetField ("LeadsPortal::AreaCodeFilterSettings")

                        and 

                        LeadsPortal::LeadDocStatus ≠ "Dead Deal" and 
                        LeadsPortal::LeadDocStatus ≠ "Docs In" and 
                        LeadsPortal::LeadDocStatus ≠ "Deal Funded"  and 

                        ((LeadsPortal::CallBackDateMoneyReady      ≤      Get(CurrentDate) and LeadsPortal::CallBackTime ≤ Get(CurrentTime)  and
                        LeadsPortal::CallBackDate     ≤    Get(CurrentDate)) or
                        IsEmpty ( LeadsPortal::CallBackDate ) and IsEmpty ( LeadsPortal::CallBackDateMoneyReady )  )

                        and


                        If (
                        LeadsPortal::SalesPersonSort=16; LeadsPortal::__fkSalesAssociate;
                        LeadsPortal::__fkSalesAssociate=LeadsPortal::SalesPersonSort
                        )

                        • 9. Re: Use GetField to specify Filter Criteria
                          philmodjunk

                          But of Course, should have thought of this earlier. This won't work because you need the filter expression to evaluate for each and every related record. By using a calculation field like this, the expression is evaluated just once from the context of the first related portal record.

                          But you might do this:

                          Put this expression into a text field:

                          "Case (
                          LeadsPortal::AreaCodeFilter = "SHOW ALL"; 1;
                          LeadsPortal::AreaCodeFilter ="Eastern"; LeadsPortal::Timezone = "Eastern" or LeadsPortal::Timezone = "Eastern/Central";
                          LeadsPortal::AreaCodeFilter ="Central"; LeadsPortal::Timezone = "Central" or LeadsPortal::Timezone = "Central/Mountain";
                          LeadsPortal::AreaCodeFilter ="Mountain"; LeadsPortal::Timezone = "Mountain" or LeadsPortal::Timezone = "Mountain/Pacific";
                          LeadsPortal::AreaCodeFilter ="Pacific"; LeadsPortal::Timezone = "Pacific" or LeadsPortal::Timezone = "Mountain/Pacific";
                          )"

                          Note the enclosing quotes.

                          Then make your portal filter expression: Evaluate ( Refer to your text field Here )

                          The main draw back to this approach is that if you later rename a field or table occurrence used in this expression, the quoted text remains unchanged and your filter fails to work.

                          • 10. Re: Use GetField to specify Filter Criteria
                            philmodjunk

                            And it looks like your "filter" field is defined in the wrong table. It should be defined in the layout's table, not the portal if you expect to select one value for the filter field and have it affect all the records in the portal. You could make it a global field, but this creates update issues you won't have to deal with if you use a non-global field defined in the layout's table. (Just be sure to commit records each time you change the value of this field.)

                            • 11. Re: Use GetField to specify Filter Criteria
                              JamesPeragine

                              I am using a Global Field, however, I will consider your method.

                              Well thank you:)  I don't fully understand why it will not evaluate every record in my portal without using the Evaluate Function.  What is the reason for this?

                              • 12. Re: Use GetField to specify Filter Criteria
                                philmodjunk

                                Put your original calculation field on the layout where you can see the value. Temporarily remove the portal filter. Compare the result returned by the calculation field with the portal records. With which portal record is the result of the calculation field consistent?

                                • 13. Re: Use GetField to specify Filter Criteria
                                  JamesPeragine

                                  I'm not sure I understand.  I put my calculation field that contains

                                  Case (
                                  LeadsPortal::AreaCodeFilter = "SHOW ALL"; 1;
                                  LeadsPortal::AreaCodeFilter ="Eastern"; LeadsPortal::Timezone = "Eastern" or LeadsPortal::Timezone = "Eastern/Central";
                                  LeadsPortal::AreaCodeFilter ="Central"; LeadsPortal::Timezone = "Central" or LeadsPortal::Timezone = "Central/Mountain";
                                  LeadsPortal::AreaCodeFilter ="Mountain"; LeadsPortal::Timezone = "Mountain" or LeadsPortal::Timezone = "Mountain/Pacific";
                                  LeadsPortal::AreaCodeFilter ="Pacific"; LeadsPortal::Timezone = "Pacific" or LeadsPortal::Timezone = "Mountain/Pacific";
                                  )

                                  on my layout and cleared my portal filter criteria.  The result of my portal will include all unfiltered records and my calculation field stays the same of coarse.  Am I missing a step?

                                  • 14. Re: Use GetField to specify Filter Criteria
                                    JamesPeragine

                                    Not sure what I'm doing wrong but I have this in my Filter Criteria 

                                    Evaluate (LeadsPortal::AreaCodeFilterSettings)

                                    and 

                                    LeadsPortal::LeadDocStatus ≠ "Dead Deal" and 
                                    LeadsPortal::LeadDocStatus ≠ "Docs In" and 
                                    LeadsPortal::LeadDocStatus ≠ "Deal Funded"  and 

                                    ((LeadsPortal::CallBackDateMoneyReady      ≤      Get(CurrentDate) and LeadsPortal::CallBackTime ≤ Get(CurrentTime)  and
                                    LeadsPortal::CallBackDate     ≤    Get(CurrentDate)) or
                                    IsEmpty ( LeadsPortal::CallBackDate ) and IsEmpty ( LeadsPortal::CallBackDateMoneyReady )  )

                                    and


                                    If (
                                    LeadsPortal::SalesPersonSort=16; LeadsPortal::__fkSalesAssociate;
                                    LeadsPortal::__fkSalesAssociate=LeadsPortal::SalesPersonSort
                                    )

                                     

                                    and this in my global text field

                                    "Case (

                                    LeadsPortal::AreaCodeFilter = "SHOW ALL"; 1;

                                    LeadsPortal::AreaCodeFilter ="Eastern"; LeadsPortal::Timezone = "Eastern" or LeadsPortal::Timezone = "Eastern/Central";

                                    LeadsPortal::AreaCodeFilter ="Central"; LeadsPortal::Timezone = "Central" or LeadsPortal::Timezone = "Central/Mountain";

                                    LeadsPortal::AreaCodeFilter ="Mountain"; LeadsPortal::Timezone = "Mountain" or LeadsPortal::Timezone = "Mountain/Pacific";

                                    LeadsPortal::AreaCodeFilter ="Pacific"; LeadsPortal::Timezone = "Pacific" or LeadsPortal::Timezone = "Mountain/Pacific";

                                    )"

                                     

                                     

                                    And it won't filter.  The portal is empty no matter what.

                                    1 2 Previous Next