7 Replies Latest reply on Mar 5, 2013 3:51 PM by philmodjunk

    Chnage portal filter via script

    Kirk_1

      Title

      Chnage portal filter via script

      Post

           Can I change a portal filter via a script step, if so how?

           I know i can open it and change it, but can i set up a button to run a script step?

        • 1. Re: Chnage portal filter via script
          philmodjunk

               I think you need to describe what you want in more specific detail.

               You cannot directly redefine the calculation expression used, but you can change the values referenced by that expression. In other words, your script can change the values in fields or variables referenced in that expression.

               You might have this expression:

               LayoutTable::GlobalNameField = PortalField::NameField

               Then your button click can put different names in the GlobalNameField to get the portal to filter on different names.

               You can even store the expression as a text field and then your portal filter expression might be:

               Evaluate ( Table::Textfield )

               so that your button click can assign a different expression to the text field in order to get a different filter expression.

          • 2. Re: Chnage portal filter via script
            Kirk_1

                 I have Boolean check boxes for; Available, Covered, Dispatched, Loaded...

                 My employees want to see shipments sorted by these characteristics.

                 i used a portal in this instance because i can limit  the invoices each sales person see's via a relationship. (they see only theirs) 

                 So I'm trying to filter the portal by the above criteria... If       invoice::INCovered =1 sort by covered 

            • 3. Re: Chnage portal filter via script
              philmodjunk

              sort by or select by?

                   If Invoice::INCovered = 1 do you only want to see related records in the portal where this field has the value 1?

              • 4. Re: Chnage portal filter via script
                Kirk_1

                     Yes

                • 5. Re: Chnage portal filter via script
                  philmodjunk

                       I don't know the context of the layout where you have placed your portal. I'll refer to the layout's table occurrence (which is named in Layout setup in the "show records from" drop down), to be "LayoutTO".

                       So if you have this relationship:

                       LayoutTO::anyField X Invoices::anyfield

                       An unfiltered portal to Invoices will display all records from the invoices table. Other relationships can be used here, this is just to get things started.

                       Then this portal filter can work off of boolean check box fields defined in the Layout's table:

                       If ( LayoutTo::Available ; Invoices::INAvaliable ) or
                       If ( LayoutTO::Covered ; Invoices::INCovered ) or
                       If ( LayoutTO::Dispatched ; Invoices::INDispatched ) or
                       If ( LayoutTO::Loaded ; INvoices::INLoaded )

                       I'd experiment with this basic approach. You may find that you don't need the If functions and can just use:

                       Invoices::INAvaliable or Invoices::INCovered or Invoices::INDispatched...

                  • 6. Re: Chnage portal filter via script
                    Kirk_1

                         Thats actually a great idea. I can use that else where to clean up a few things.

                         Thank you

                    • 7. Re: Chnage portal filter via script
                      philmodjunk

                           But note that you may have issues getting the portal to update after you change the values in one of the checkboxes in the related table.

                           You can use Refresh WIndow [Flush cached joine results]

                           or you can include each of the layout fields referenced in the portal filter as a match field in the relationship using the X operator and the portal will update without the added script.