Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

This topic is 4387 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Posted

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!

  

 

 

Posted

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. 

This topic is 4387 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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