Go To Related Record - Error Codes
Go To Related Record - Error Codes
am 28.11.2007 18:10:04 von KevinSmith
If you were in list and want to show all related records you would
use: Go To Related Record - Matching All Records in Current Found Set.
I found the easiest way to find out if there are any related records
is to use the Get Last Error function. I got stuck trying to do this:
If Get (LastError)<>0
I got an error even when there WERE related records. I though you
might find it useful to know how it works. It turns out that the
system does the following:
Each record in source table has a related records in destination
table Get (LastError) =0
One or more records in source table does not have a related record in
destination table
Get (LastError) =101 [ Record is missing ]
There were no related records in destination table. User is left
viewing source table.
Get (LastError)= 401 [No records match the request ]
Kevin Smith
Re: Go To Related Record - Error Codes
am 28.11.2007 20:02:44 von Chris Brown
KevinSmith wrote:
> If you were in list and want to show all related records you would
> use: Go To Related Record - Matching All Records in Current Found Set.
> I found the easiest way to find out if there are any related records
> is to use the Get Last Error function. I got stuck trying to do this:
> If Get (LastError)<>0
>
> I got an error even when there WERE related records. I though you
> might find it useful to know how it works. It turns out that the
> system does the following:
>
> Each record in source table has a related records in destination
> table Get (LastError) =0
>
> One or more records in source table does not have a related record in
> destination table
> Get (LastError) =101 [ Record is missing ]
>
> There were no related records in destination table. User is left
> viewing source table.
> Get (LastError)= 401 [No records match the request ]
>
> Kevin Smith
alternatively you might use a count of related records
Table A, table B
If [ Count ( B::ID_B ) = 0 ]
Show Custom Dialog [ Message: "no related records"; Buttons: OK,
Cancel ]
Else
Go to Related Record [ From table: B; Using layout: B (B) ]
[ Show only related records ]
End If
Re: Go To Related Record - Error Codes
am 28.11.2007 22:27:36 von KevinSmith
Hi Chris
Thanks for taking an interest in my observations. Oh, and apologies
for the wobbly grammar at the start of the original post.
I think the method you describe below will work when you are viewing
records ONLY related to the current record. The "LastError" method is
necessary when you wish to view ALL records RELATED to the current
found set.
I've been working at this one since the original post. When doing a
"Go To Related Record - Matching All Records in Current Found Set" you
need to ignore error code 101. Error 401 is a valid error i.e. no
found records in destination table.
Regards
Kevin Smith
On Nov 28, 7:02 pm, Chris Brown
wrote:
> alternatively you might use a count of related records
> Table A, table B
>
> If [ Count ( B::ID_B ) = 0 ]
> Show Custom Dialog [ Message: "no related records"; Buttons: "OK",
> "Cancel" ]
> Else
> Go to Related Record [ From table: "B"; Using layout: "B" (B) ]
> [ Show only related records ]
> End If
Re: Go To Related Record - Error Codes
am 29.11.2007 23:08:18 von Chris Brown
KevinSmith wrote:
> Hi Chris
>
> Thanks for taking an interest in my observations. Oh, and apologies
> for the wobbly grammar at the start of the original post.
>
> I think the method you describe below will work when you are viewing
> records ONLY related to the current record. The "LastError" method is
> necessary when you wish to view ALL records RELATED to the current
> found set.
>
> I've been working at this one since the original post. When doing a
> "Go To Related Record - Matching All Records in Current Found Set" you
> need to ignore error code 101. Error 401 is a valid error i.e. no
> found records in destination table.
>
> Regards
> Kevin Smith
>
> On Nov 28, 7:02 pm, Chris Brown
> wrote:
>
>> alternatively you might use a count of related records
>> Table A, table B
>>
>> If [ Count ( B::ID_B ) = 0 ]
>> Show Custom Dialog [ Message: "no related records"; Buttons: "OK",
>> "Cancel" ]
>> Else
>> Go to Related Record [ From table: "B"; Using layout: "B" (B) ]
>> [ Show only related records ]
>> End If
>
>
I suppose I would have approached no related records for found set by
testing a layout change (SP = ALL) a la:
grr
If [ Get ( ScriptParameter ) = "ALL" ]
Set Variable [ $_LAY; Value:Get ( LayoutNumber ) ]
Go to Related Record [ From table: B; Using layout: B (B) ]
[ Show only related records; Match found set ]
Show Custom Dialog [ Message: "There appears to be no related records";
Buttons: OK ]
If [ Get ( LayoutNumber ) = $_LAY ]
End If
Else
If [ Count ( B::ID_B ) = 0 ]
Show Custom Dialog [ Message: "no related records"; Buttons: OK ]
Else
Go to Related Record [ From table: B; Using layout: B (B) ]
[ Show only related records ]
End If
End If
but having tested error 401, it achieves the same result
regards
Chris