Jump to content
Sign in to follow this  
lonesomejubilee

adding a new record and relating it to another

Recommended Posts

Hi,

I want to make a button that will open a second window, add a new record, but place the current record (from first window)'s ID in a field. It tried to script it using the SET FIELD,... with field::fieldID, but it doesn't work, can anyone help me out?

Basically I am trying to avoid turning the create records in portal situation.

lj

Share this post


Link to post
Share on other sites

the button above the portal would be "Add Line Item" and would:

Set field (globalfield to current records's id)

New Window

Go to Layout (layout based on table occurrence for the line items)

New Record

Set foreign key field to globalfield

Are you showing the user a popup where they enter the line item info?

Share this post


Link to post
Share on other sites

Yeah, I wanted to make a popup window when they click the "add line item" button. I'll try to do what you suggested (if I can figure it out). I'll let you know in a few... thanks!

Share this post


Link to post
Share on other sites

Worked like a charm! My question now is, why didn't my way worked? I tried basically same thing... does it have something to do with the way a global field works?

I just tried to set field foreign key = primary key of 1st table, but it was a no go...

You suggest the same thing except by transfering the primary key to the global field and it works! must have to do with globals!

Thanks Very Much!!!

Lonesomejubilee

Share this post


Link to post
Share on other sites

Yours didn't work because when you open the new window, the context changes, and from the new window, FM doesn't know what value to use. BTW, you can set up your button to pass the ID as a script parameter, and not use a global field.

Your script then might be:

If [get(ScriptParameter <> "" /* prevents empty record creation */]

New Window

Go To Layout["My Layout"]

New Record []

Set Field [iD, Get(Scriptparameter]

Commit Record[]

End if

David

Share this post


Link to post
Share on other sites

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
Sign in to follow this  

×

Important Information

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