AnsweredAssumed Answered

Delete portal row not working - get(FoundCount) reports 1 too many records

Question asked by disabled_JustinClose on May 15, 2015
Latest reply on May 22, 2015 by disabled_JustinClose

Title

Delete portal row not working - get(FoundCount) reports 1 too many records

Post

Hey all,

I'm using FMPA 14 and I'm having an issue with a 'delete portal row' script step.  The step itself appears to work correctly, and the record is disappearing - I have a second window open showing me the records I am working with while I'm developing this.  After deleting that portal row/record the same script goes off to a utility layout, finds the remaining related records, and tries to reserialize them.  However, it is failing because I check for the proper count of records before doing this 'replace field contents' step.

The relationship is a simple Parent-Child table:  TableA::RecID = TableB::ID_fk

Here are the script steps involved; the reserialize part is actually another script, but I copied the steps out of it and combined it into one so I could export the steps.  (I tried to make it look nice, exporting to PDF is a bit of chore.  And this forum editor doesn't appear to respect different formats I apply to sections, e.g. 'preformated'.)  Also, if there are missing if/end-ifs, don't worry about it too much, it's just my pasting job - the script otherwise works fine, and this is just a portion of it:

----------------------------------
Delete Portal Row [ No dialog ]
Set Variable [ $LastError; Value:Get(LastError) ]

If [ $LastError = 0 ]
    Go to Object [ Object Name: "3_1" ]
    If [ ScratchBooking::Traveler_Count_uc = 1 ]
        Go to Object [ Object Name: "2_1" ]
        Set Field [ ScratchBooking::Option_g; "Single" ]
    Else
        Set Field [ ScratchBooking::Option_g; "" ]
    End If

    Perform Script [ “Reserialize”; Parameter: List ( 123 ; Scratch::Count_uc ]

        #--------------------     (2nd script starts here...)

        Set Variable [ $SetID; Value: GetValue( Get(ScriptParameter) ; 1 ) ]
        Set Variable [ $SetCount; Value: GetValue( Get(ScriptParameter) ; 2 ) ]
        If [ IsEmpty ( $SetID ) ]
        ...
        Else
            New Window [ Style: Document; ... ]
            Go to Layout [ “Scratch_Child UTIL” (Scratch_Child) ]
            Enter Find Mode [ ]
            Set Field [ Scratch_Child::ID_fk; $SetID ]
            Set Error Capture [ On ]
            Perform Find [ ]
            If [ Get(FoundCount) = $SetCount ]     <-----  Problem shows up here!
                Replace Field Contents [ Scratch::Position; Replace with serial numbers: ... ]
                Set Variable [ $LastError; Value:Get(LastError) ]
                If [ $LastError ≠ 0 ]
                    Set Variable [ $ExitResult; Value:"Error: 1" ]
                End If
            End If
        End If
End If

--------------------------------------------------

I put a pointer on the line where the problem crops up.  The $SetCount being passed in is correct (e.g. 1 record).  The issue is at the 'Get(FoundCount)' step:  it reports 2 records found, when there is only 1 record...there's only 1 record in the entire table!  Is this a problem were the local cache of the DB still has the record present?  My spare window I mentioned, showing the Child table, shows one record in the entire table; this other window updated immediately when the portal row record was deleted.

 

Thanks,

Justin

Outcomes