AnsweredAssumed Answered

create related record in all records

Question asked by BKamp on Feb 2, 2017
Latest reply on Feb 4, 2017 by philmodjunk

Hi guys,

 

I have the following tables:

  • contactdetails
  • payouts (uitkeringen)
  • payouts temporary (tijdelijke_uitkeringen)

 

contactdetails is the primary table, uitkeringen is related to it trough contactdetails pk. On the contactdetails layout I have a portal to payouts.

payouts temporary is standalone, it is used to enter data that should be created in every contact's related record payout.

 

so on the payouts temporary layout I have the same fields as in payouts portal on contactdetails. I want to populate them in payouts temporary and be able to press a button to run the following script that creates a payout for every contactperson in my db.

 

Off course it's not working and I'm wondering why, when I press the button for the script, it just runs and does nothing until I press esc.

 

here's the script:

 

Set Variable [ $fonds; Value:tijdelijke_uitkeringen::fonds ]

Set Variable [ $kwartaal; Value:tijdelijke_uitkeringen::kwartaal ]

Set Variable [ $jaar; Value:tijdelijke_uitkeringen::jaar ]

Set Variable [ $datum; Value:tijdelijke_uitkeringen::uitkeringsdatum ]

Set Variable [ $koers; Value:tijdelijke_uitkeringen::uitkeringskoers ]

Set Variable [ $percentage; Value:tijdelijke_uitkeringen::uitkeringspercentage ]

Go to Layout [ “Contactdetails” (Contactpersonen) ]

Go to Record/Request/Page [ First ]

Loop

#check if the member is a member of the fund that the uitkering was created for

Go to Related Record [ From table: “Uitkeringen”; Using layout: “Uitkeringen” (Uitkeringen) ]

New Record/Request
Set Variable
[ $error; Value:Get ( LastError ) ]
Exit Loop If [ Get(LastError) <> 0 ]

Set Field [ Uitkeringen::fonds; $fonds ]

Set Variable [ $error; Value:Get ( LastError ) ]

Exit Loop If [ Get(LastError) <> 0 ]

Set Field [ Uitkeringen::kwartaal; $kwartaal ]

Set Variable [ $error; Value:Get ( LastError ) ]

Exit Loop If [ Get(LastError) <> 0 ]

Set Field [ Uitkeringen::jaar; $jaar ]

Set Variable [ $error; Value:Get ( LastError ) ]

Exit Loop If [ Get(LastError) <> 0 ]

Set Field [ Uitkeringen::uitkeringsdatum; $datum ]

Set Variable [ $error; Value:Get ( LastError ) ]

Exit Loop If [ Get(LastError) <> 0 ]

Set Field [ Uitkeringen::uitkeringskoers; $koers ]

Set Variable [ $error; Value:Get ( LastError ) ]

Exit Loop If [ Get(LastError) <> 0 ]

Set Field [ Uitkeringen::uitkeringspercentage; $percentage ]

Set Variable [ $error; Value:Get ( LastError ) ]

Exit Loop If [ Get(LastError) <> 0 ]

Go to Record/Request/Page [ Next; Exit after last ]

End Loop

 

Set Variable [ $error; Value:Get ( LastError ) ]

 

If [ Get(LastError) <> 0 ]

Revert Record/Request [ No dialog ]

Show Custom Dialog [ Title: "Error"; Message: $error; Default Button: “OK”, Commit: “Yes”; Button 2: “Cancel”, Commit: “No” ]

End If

 

Outcomes