AnsweredAssumed Answered

Adding new related record in portal script...

Question asked by alinicjones on Oct 13, 2014
Latest reply on Nov 1, 2016 by dig

I can't quite figure out what i'm missing in these script steps to get the portal to go to the next record. instead it updates the record that was previously created. See script steps below.

 

Tables:

Student

Rotation

 

The portal is based off of the Student_Rotation relationship.

 

The Rotation portal is located on the Student layout. i have a button that opens a popover where a period is slected and then the service. OnObjectEnter is on the portal, it is set to perform the "Add New Rotation" script. The purpose is to Create a new record set the current records Student ID number.

 

Add New Rotation

Set Error Capture [On]

Allow User Abort [Off]

#

Set Variable [ $StudentID; Value: Student::__kp_StudentID

#

New Window [Name: "New Rotation"; Top:10000; Left: 10000; Style: Document ]

Go to Layout ["dev_rotation" (Rotation) ]

New Record/Request

Set Field [Rotation::_kf_StudentID; $StudentID ]

Commit Records/Request [ No dialog]

Close Window [Current Window]

Refresh Window [Flush cached join results]

#

If [Get (ActiveLayoutObjectName ) = "Button | Select Period"

Perform Script [ "Popover | Add New Rotation_Period" ]

Else If [ Get ( ActiveLaoyoutObjectName ) = "Button | Select Service" ]

Perform Script [ "Popover | Add New Rotation_Service" ]

End If

 

on this popover i have a button where they select the appropriate period for the rotation.

Add Period.png

The script for this button is:

 

Popover | Add New Roation_Period

Set Error Capture [On]

Allow User Abort [Off]

#

If [not IsEmpty ( Get (ScriptParameter ) ) ]

Set Variable [ $SELECTED_Period; Value: Get ( ScriptParameter ) ]

End If

Go to Field [ student_ROTATION::PeriodName ]

Go to Portal Row [ Select; First ]

Set Field [ student_ROTATION::_kf_PeriodID; GetValue ( $SELECTED_Period; 1 ) ]

Set Field [ student_ROTATION::PeriodName; GetValue ( $SELECTED_Period; 2 ) ]

#

Set Script Animation [On]

Go to Object [ Object Name: "Select Service"

 

There is a slide control in the popover. Once the period is selected it 'slides' to the service selection area of the popover.

Add Service.png

in this section there is another button that triggers the script

 

Popover | Add New Rotation_Service

Set Error Capture [On]

Allow User Abort [Off]

#

If [not IsEmpty ( Get (ScriptParameter ) ) ]

Set Variable [ $SELECTED_Service; Value: Get ( ScriptParameter ) ]

End If

Go to Field [ student_ROTATION::ServiceName ]

Go to Portal Row [ Select; Previous]

Set Field [ student_ROTATION::ServiceName; GetValue ( $SELECTED_Service; 1 ) ]

Set Field [ student_ROTATION::_kf_ServiceID; GetValue ( $SELECTED_Service; 2 ) ]

#

Commit Records/Request [No dialog]

Set Script Animation [On]

Got to Object [Object Name: "Select Period" ]

Close Popover

#

Refresh Window [Flush cashed join results]

 

Student Rotation.png

The first records works fine but when i try to add a new rotation it updates the record that was just created. I'm sure i have something out of order or i'm missing a script set or something. I have tried a number of different thing but i can't seem to get it to work right. Any help would be wonderful!!

Thank you in advance!

Outcomes