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.

SetFieldByName for related record in a portal

Featured Replies

post-105335-0-54252600-1353111388_thumb.Hello all. I am trying to copy data from portal records into another related table (both share the same parent record as below) in order to populate binary fields for data analysis from a more flexible portal-based records structure.

 

  Analysis_Variables l------------l Patients l------------l Patient_Autopsy ------< Patient_Infarcts

 

A patient will only ever have one record in the Analysis_Variables or Patient_Autopsy tables (that is created when necessary), but an autopsy can have multiple infarcts (entered via a portal "Infarcts" on a layout displaying records from Patient_Autopsy).

 

In Analysis_Variables, I have created fields for binary data input that have this shared naming structure: "Analysis_Variables::Autopsy_Infarct#_Trait". For each infarct #, there are 5 traits of interest (field names are specific for these in my database, just simplified here for ease of generalizability). My script currently looks like this:

 

Go to Object ["Infarcts"]

Go to Portal Row [select; First]

Set Error Capture [On]

Set Variable [$row; Value:1]

Loop

   Exit Loop If [isEmpty(pk.InfarctID)]

   Set Variable [$Trait; Value: Patient_Infarcts::Trait]

       etc. (repeat for all record traits of interest)

   New Window [Name:"Infarcts"]

   Go to Object ["Variables"]

   Go to Portal Row [select; First]

   Set Field By Name ["Analysis_Variables::Autopsy_Infarct" & $row & "_Trait" ; $Trait]

   Set Variable [$Trait ; ""]

   Close Window

   Set Variable [$Row ; Value: $Row + 1]

End Loop

 

When I get to the "Set Field By Name" step, I get Error 415 back ("Related Record Required"). I have a few ideas as to why, but I'm wondering if someone can help me fix my script and/or propose a more elegant solution. I've attached a doctored screenshot of my database to help clarify what I'm doing and how everything is layed out. The main record it was taken from is from Patient_Autopsy.

 

Thanks so much!

  

 

 

Do you really have multiple fields for infarcts, "Autopsy_Infarct1_Trait", "Autopsy_Infarct2_Trait", "Autopsy_Infarct3_Trait", etc on you Analysis table?  From you layout it looks like they are actually repeating fields.  If they are repeating fields then you will need to specify the repetition number in the SetFieldByName script step.  If these are not repeating fields then you might want to simplify your solution somewhat.  Can't you just display the same information through a relationship in a portal or a calculation, rather than running a script to transfer the data from one table to another?   There can be good reasons to copy the same data from one table to another, e.g. if you want to capture what the data looked like at a certain point in time.  If you are just displaying the same data in a different layout on the the page, a second table may not be ideal. 

 

As far as your error code goes, are you trying to create a related record via the SetFieldByName step?  If so, you need to allow creation of related records in your relationship graph. 

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.