1 Reply Latest reply on Nov 18, 2011 8:27 AM by philmodjunk

    Access records in a portal



      Access records in a portal


      I have a Case table where each case can have a set of financial Ledger records associated with it.

      Each month the loans are processed and interest is calculated by applying the interest to each transaction. (That bit I can do)

      I then want to go through the Ledger records collect up the individual interest, by Case, and add this total to the balance in the Case record.

      I have tried using the portal option - new layout with the Portal control on it - with no success

      I have tried the script below.  

      Set Variable [ $TotalLedger; Value:0 ] 
      Go to Layout [ “portLedger” (aflCase) ]   ' The layout holds the portal holding the ledger records filtered for the selected Case
      Go to Portal Row 
      [ Select; First ]      ' Start at the first record of the selection. This seems to take the pointer to the first record in the Ledger table.

           Set Variable [ $TotalLedger; Value:$TotalLedger  + aflLedger::ledNetAmount ]    ' Do the calculation to consolidate the entries
           Go to Record/Request/Page [
      Next; Exit after last ] 

      End Loop 

      Go to Layout [ “aflCase” (aflCase) ] 
      Set Field [ aflCase::casEoMBalance; $TotalLedger ]     ' Save the amount in the relevant case field

      The above works in a way but it always picks the same set of Ledger records regardless of which Case has been selected.

        • 1. Re: Access records in a portal

          Since you have the related records in a portal, why not let the portal's relationship , work for you so that you do not need a looping script?

          If you have this relationship:

          ParentTableOccurrence::PrimaryKey = PortalTableOccurrence::ForeignKey //use your names in place of these


          Sum ( PortalTableOccurrence::LednetAmount )

          Will retun the total of LedNetAmount for all portal records related to that parent record.

          If you have a portal filter expression involved and you only want to compute the total of the records shown in the filtered portal, a different approach will need to be used.

          Note that a summary field computing the total of LednetAmount, defined in the portal's table can also be used to compute this same total.