Jump to content
Server Maintenance This Week. ×

adding a new record and relating it to another


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

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

Link to comment
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?

Link to comment
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

Link to comment
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

Link to comment
Share on other sites

This topic is 6198 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.