AnsweredAssumed Answered

How to write a script to auto enter a foreign key.

Question asked by tap4pat on Jan 15, 2019
Latest reply on Jan 15, 2019 by keywords
  1. I have a layout that is based on my Monthly Hours Table. This table is related to my Members Table.
  2. In that layout I have a portal based on the Responders Table.
  3. The Responders Table is related to my Member Table, which has all of the information on each person on the team.
  4. To relate everything together I have a Members Foreign Key in both the Responders Table and Monthly Hours Table.
  5. For the Monthly Hours Table I have the Members Unit Number & Name. I have these auto enter when a member creates a new record, using a new record button. The script takes the login name and parses it to look up the primary key in the Member Table. I then copy that value and paste it into my Member_Foreign Key field. That causes an auto lookup of the members Unit # and Name from the relationship Member::PrimaryKey to MonthlyHours::Member_ForeignKey.
  6. I want to do the same sort of thing when I click into the Member_ForeignKey in the responder portal. Or if possible when I click into the date field, thus not having anyone click into the Member_ForeignKey field.
  7. The Member_ForeignKey in the Responder Portal is stacked on top of the Unit # Field.
  8. I do store the Member_ForeignKey into a global value, $$Member_FK, when a person logs into the solution.

Screen Shot 2019-01-15 at 6.29.02 PM.png

Screen Shot 2019-01-15 at 6.29.23 PM.png

This is my new record script that fills the information in the Monthly Hours portion of the layout:

Screen Shot 2019-01-15 at 6.33.53 PM.png

I tried this, but am stumped. As well as I'm having trouble navigating portals.

Screen Shot 2019-01-15 at 6.37.03 PM.png