0

Create records question

Hi all -

Here is what I'm trying to do with a button:

let curRec := Id;
let xLoc := curRec.Location.LocationID;
let xTeam := curRec.Team.TeamID;
let xCreate := (create 'Event Results');
xCreate.(Results := curRec);
xCreate.Location.(LocationID := xLoc);
xCreate.Team.(TeamID := xTeam);
openRecord(xCreate)

When I click the button, the record gets created but the fields in the new record in the new table does not get transferred.

Some background, I'm in my Results table. There are two fields that are links to other tables (Location and Team). I want to copy these two bits of information from my record in the Results table and create a new record in Event Results that also links to the Location and Team table. But I can't seem to get the info from link to copy over.

Thanks in advanced for any help.

7 replies

null
    • Sean
    • 3 yrs ago
    • Reported - view

    Fred, try...

     

    let curRec := this

     

    You are only assigning the Id of the current record to the variable.

    • Fred
    • 3 yrs ago
    • Reported - view

    Hi Sean -

    I switched it and still the Location and Team data does not get transfered.

    • Sean
    • 3 yrs ago
    • Reported - view

    Hi Fred,

    The way I'm reading this is Location and Team are the "1" tables and Results and Event Results are the "N" tables (you didn't mention a many-to-many relationship). If that's the case, you shouldn't need to copy the information over to Event Results. The information is already in the Location and Team tables so all you should need to do is create the link to Event Results.

    • Fred
    • 3 yrs ago
    • Reported - view

    Hi Sean -

    I keep forgetting to mention the relationships. Results is N>1 to Location and Teams. Event Results is also N>1 to Location and Teams.

    You are correct, my terminology is incorrect. I am trying to create a link in Event Result to Location and Team and that is not happening.

    • Sean
    • 3 yrs ago
    • Reported - view

    Fred,

    I tried to come up with a solution before leaving for work, but no luck. I'll try again tonight.

    • Fred
    • 3 yrs ago
    • Reported - view

    Hi Sean -

    Looks like once you pointed me in the right direction I was able to find other solutions and some bumbling around. Here is the final code that worked.

    let curRec := this.Id;
    let xCreate := (create 'Event Results');
    xCreate.(Location := curRec.Location);
    xCreate.(Team := curRec.Team);
    openRecord(xCreate)

    Thanks for your help.

    • Sean
    • 3 yrs ago
    • Reported - view

    Hi Fred,

    I'm glad you got it working. Nothing wrong with finding other solutions or bumbling around. My Mac app is littered with test databases.

     

    I appreciate someone who is willing to try to figure it out as opposed to someone with a ratio of "Requests for help" to "Assistance given" posts in the range of 200+ to 0.

Content aside

  • 3 yrs agoLast active
  • 7Replies
  • 663Views