6 Replies Latest reply on Nov 25, 2014 7:37 AM by episking

    Validation on Related Repeating Records in Portal

    episking

      Title

      Validation on Related Repeating Records in Portal

      Post

      I have a layout that contains a repeating portal which contains among other items a field called "Instance".  This field is required for each line item.

      Currently, I have a submission script that does all the data validation, but I can't seem to get the script to validate all of the "Instance" fields in the related, repeating portal.  It works for the first line item in the portal, but not for the additional line items.

      Thanks for your help!

      -EP

        • 1. Re: Validation on Related Repeating Records in Portal
          philmodjunk

          Care to share that script so that we might see where changes may be needed?

          • 2. Re: Validation on Related Repeating Records in Portal
            episking

            ....Other validation rules...

            If [Purchase_Request::Billable to Client = "Yes" and Purchase_Request_Items::Instance = ""]
                 Show Custom Dialog ["Error"; "Each line item is billable and requires and instance."]
                 Exit Script []
            End If

            ...Other validation rules...

            • 3. Re: Validation on Related Repeating Records in Portal
              philmodjunk

              If Purchase_Request is your related table referenced by your portal, this code will only reference the values in the first such related record. Values in any additional related portal records will not be referenced in this If step.

              You'd need to loop through these records (or the rows of your portal) to check them one at a time, or look at the values in aggregate, such as using the List and FilterValues functions. I can't quite spell out the details for you as I do not know if you want this error message to appear if any row with "Billable..." = to "Yes" and Instance empty is true or only if all the records in the portal meet this criteria.

              • 4. Re: Validation on Related Repeating Records in Portal
                episking

                Purchase_Request is the main Table in use on this layout.  Purchase_Request_Items is the related table that is in use in the portal.

                Billable = Yes is a radio button that applies to the entire Purchase_Request layout, so when Billable = Yes, each line item in related table Purchase_Request_Items will require Purchase_Request_Items::Instance, otherwise it prompts the user to fix the issue and exits the script.

                Thanks!

                -EP

                • 5. Re: Validation on Related Repeating Records in Portal
                  philmodjunk

                  The same rules apply in that case. Purchase_Request_Items::Instance = "" will only reference the first portal records unless you eitehr loop through them one at a time or examine the values in aggregate (as a set of values).

                  ValueCount ( List ( Purchase_Request_Items::Instance  ) ) = count ( Purchase_Request_Items::ForeignKeyFieldHere )

                  Will not be true if the Instance field is empty for any record in the portal. (This assumes an unfiltered portal as these calculations ignore portal filters.)

                  • 6. Re: Validation on Related Repeating Records in Portal
                    episking

                    Excellent.  I did the following and it works perfectly.

                    If [Purchase_Request::Billable to Client = "Yes"]

                      If [ValueCount ( List ( Purchase_Request_Items::Instance ) ) = Count ( Purchase_Request_Items::pr_docKey )]

                      Else

                        Show Custom Dialog [ Error ]

                        Exit Script []

                      End If

                    End If

                     

                    Works great.

                     

                    Thank you!!