7 Replies Latest reply on Aug 7, 2013 2:52 PM by philmodjunk

    Portal and Value List

    Vicky

      Title

      Portal and Value List

      Post

           Hi,

           Is it possible to have a field with a value list change automatically based on another field in a portal? 

           OrderLineItems|ByOrder > --- - Order

           OrderLineItems|ByOrder:: _fkOrderID = Order :: _pkOrderID

            In the picture I uploaded, the ETA Status (Order) at the top has a value list containing "Pending" , "Open" , "Ship" , and "Closed" . The user needs to be able to manually select between from Pending and Open. After Open is selected, when a line in the portal ETA Status(OrderLineItems|ByOrder) becomes Ship, ETA Status (Order) should automatically change to Ship. When all the lines in portal become Closed, ETAStatus(Order) automatically changes to Closed.

      Screen_Shot_2013-08-06_at_3.26.28_PM.png

        • 1. Re: Portal and Value List
          philmodjunk

               You'd need to set an onObjectSave script trigger on the ETA status field that checks the values of this field for all related records and then updates the field at the top of the layout if needed.

               Something like:
               If [ OrderLineItems|ByOrder::ETA Status = "Ship" ]
                  Set Field [ Orders::ETA Status ; "Ship" ]
                  If [ Count ( OrderLineItems|ByOrder::_fkOrderID ) = ValueCount ( FilterValues ( List ( OrderLineItems|ByOrder::ETA Status) ; "Ship" ) ]
                        Set Field [ Orders::ETA Status ; "Closed" ]
                  End If
               End IF

          • 2. Re: Portal and Value List
            Vicky

                 Hi Phil,

                 I tried your suggestion but I think I am doing something wrong. The OrderLineItems|ByOrder::individualETAStatus is a calculation. Will that affect the script?

                 OrderLineItems|ByOrder :: individualETAStatus=
                 Case( 
                      Order::estimatedTimeOfArrivalStatus = "Pending" ; "Pending";
                      If ( Order::estimatedTimeOfArrivalStatus = "Open" or Order::estimatedTimeOfArrivalStatus = "Ship" or Order::estimatedTimeOfArrivalStatus =  "Closed" ; 
                               (Case( 
                                           IsEmpty ( shippingQuantity ) ; "Open" ; 
                                           quantity = closedQuantity; "Closed"; 
                                           shippingQuantity    ≥   0 ; "Ship"
                                        )
                                );  "Open" 
                      )
                 )
            • 3. Re: Portal and Value List
              philmodjunk

                   Yes, if the value is calculated then any data entry that modifies the value calculated does not trip the script trigger. you'd need to set on ObjectSave script triggers on any fields that a user can change to produce the change in value computed by this field.

              • 4. Re: Portal and Value List
                Vicky

                     I separated the script into one for shipping and one for closed and set it on Ship1 and Receive1, since the user will be entering values in those fields.  The ETA Status changes to Ship just fine, but Closed does not work. Is it because it cannot tell if all the lines are closed?

                • 5. Re: Portal and Value List
                  philmodjunk

                       Very possibly. The untested script that I suggested uses List to pull up a list of all such values and then uses FilterValues to compare the number of items in the list aht are marked "ship" to the total number of items in the list to identify when all line items have been so marked. There might need to be a commit records step in there to pull the focus away from a specific line item in order to get that list of all related values.

                  • 6. Re: Portal and Value List
                    Vicky

                         I added commit after the end if and it kind of works if there is only one line in the portal.  When I enter in a value in receive1, nothing changes, but if I go back into receive1 and delete the value and click outside then it becomes closed.  I tried putting it before the end if but then it doesn't work

                    • 7. Re: Portal and Value List
                      philmodjunk

                           What I had in mind was this:

                           If [ OrderLineItems|ByOrder::ETA Status = "Ship" ]
                              Set Field [ Orders::ETA Status ; "Ship" ]
                              Commit Records
                              If [ Count ( OrderLineItems|ByOrder::_fkOrderID ) = ValueCount ( FilterValues ( List ( OrderLineItems|ByOrder::ETA Status) ; "Ship" ) ]
                                    Set Field [ Orders::ETA Status ; "Closed" ]
                              End If
                           End IF