Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Grab a value in a text field and create a new record in a portal

Featured Replies

Hi

I have a problem grabbing a value in a text field containing a list.

The list is containing values from a related record and is defined: TextField = List (RelatedTable::RelatedField)

And is like:

0

10

50

100 etc.

What I want to do is to loop through this list, grab each value and create a new related record in another table an paste each value into a field.

Can anyone help me on the right track here.

Best regards,

Reynir.

create a new related record in another table an paste each value into a field.

Are you sure about this? Each value into a different field in the same record? What if there are more values than fields?

  • Author

Maybe I was not clear enough about this.

The scenario is like this:

I have a calibration program table (pk_CalibrationProgram_ID, etc. which has a related table: calibration points (one or more) (pk_CalibrationPoints_ID, fk_CalibrationProgram_ID, etc.), then I have another table calibration (pk_Calibration_ID, fk_CalibrationProgram_ID, etc.) which has a related table calibration values (pk_CalibrationValues_ID, fk_Calibration_ID, what I want is when I make a calibration record for the calibration program, then I want to copy the calibration points to new records in the calibration value table.

The CalibrationProgram table is related to the Calibration table. In the calibration table I have a portal linked to both calibration values and calibration points, Then I have a ListOfCalibrationPoints = List (CalibrationPoint::CalibrationPoint) which contains the calibration points, what I want to do is to copy each calibration point, create a new record in the CalibrationValues table and paste the calibration point into a field, CalibrationPoint in the Calibration Values table.

Hope this explains what I mean.

Reynir.

If I understand this correctly, you want to select a calibration program and then create a record in CalibrationValues for each point in that program, related to the current calibration?

If so try (from a layout of Calibrations):


Set Variable [ $calibrationID ; Calibrations::pk_Calibration_ID ]

Set Variable [ $pointIDs ; List ( CalibrationPoints::pk_CalibrationPoint_ID ) ]

Go to Layout [ CalibrationValues ]

Loop

Set Variable [ $i ; $i + 1 ]

Exit Loop If [ $i > ValueCount ( $pointIDs ) ]

New Record

Set Field [ CalibrationValues::fk_Calibration_ID ; $calibrationID ]

Set Field [ CalibrationValues::fk_CalibrationPoint_ID ; GetValue ( $pointIDs ; $i ) ]

End Loop

Commit Records

  • Author

Almost the right understanding.

Thank you very much. In the meantime I found another solution that worked fine (at least I manage to get it working the way I want)

CalibrationValue_List is the list of calibration points values.

The script is as follows:

Loop

Set Variable[ $line, 1 ]

# Loop over lines

Loop

Exit Loop If[ ValueCount( CalibrationValue_List ) < $line ]

#

# Get line values

Set Variable[ $fields, GetValue(CalibrationValue_List, $line ) ]

SetVariable[ $pk_Calibration_ID, Value: pk_Calibration_ID ) ]

Go to Layout(CalibrationValues)

New Record/Request

Set Field[ CalibrationValues::CalibrationPoint, GetValue( $fields, 1 ) ]

Set Field[ CalibrationValues::fk_Calibration_ID, $pk_Calibration_ID ) ]

Go to Layout( original layout )

Set Variable[ $line, $line + 1 ]

End Loop

This will help me a lot. I will try your solutuion as well. One more question: In your solution you commit records in the end, is there a reason to do so?

Again, thank you very much pointing me to the right track.

Best regards,

Reynir.

I can see in my reply there is one Loop to much in the beginning.

I think you'll find my version slightly more efficient. BTW, the calculation field CalibrationValue_List is not required.

In your solution you commit records in the end, is there a reason to do so?

Yes, because the last record in CalibrationValues remains uncommitted at the end of the loop.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.