Jump to content

Create related record - web


halbj
 Share

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

Recommended Posts

Ahh, create a new related record, not view them. It'll be a bit more work then.

You'll have to determine the value of the master key for the (current master) record, then use it to generate a form that (when submitted) creates a new record in the related database with the master key value inserted into the remote key field.

Not too hard, but a bit of clever logic needed.

Link to comment
Share on other sites

Ahhhh. A fancy cdml tag. How about "-new"?

There are other fancy cdml tags. They are available in the cdml reference.fp5. You can find sources for that somewhere in these forums (try cdml forum). There might even be a fancy -link tag. You really should use this valuable resource Hal.

[ September 10, 2001: Message edited by: Keith M. Davie ]

Link to comment
Share on other sites

Vaughan,

thanks, I am unsure of how to get the Primary key or Record ID of the master to be auto-entered into the new related record. Any ideas.

Keith,

good one smart *** ! - See if you can understand the question and provide some sensible suggestions.

Cheers

Hal.

Link to comment
Share on other sites

This is where the "logical approach" becomes important. Think systematically.

Step one: users sees a list of records in master database. User clicks on link on one of these records which is a URL to...

Step two: view details of one master record, where we can easily determine value of the key field using [FMP-Field: key]. The "trick" is that the master record is displayed as a form for creating the related record (-db and other tags set to add record into the related database). The key field value is simply placed into a hidden code in the form for the remote key. Clicking the Submit button activates the -New action which...

Step three: creates new record in related database with key value equal to that of the master key. Display the newly created record as per the format file specified in the previous form.

Link to comment
Share on other sites

Glad to be of help Hal. I suppose I could have recommended the use of the fancy -script tag, but then you would have encountered problems because you would need to develop a fancy workaround to the single-thread engine which handles the scripts. I believe I am the only one who has developed a successful workaround. Thus I would use a script with confidence. Scripts give your db's power.

Link to comment
Share on other sites

Vaughn - This is the code I have out on the details page of the found master record. When I click submit I get an error that the "FORM.htm" could not be found.

<FORM ACTION="FMPro" METHOD="post">

<INPUT TYPE="hidden" NAME="-DB" VALUE="RELATED">

<INPUT TYPE="hidden" NAME="-Lay" VALUE="CGI">

<INPUT TYPE="hidden" NAME="-format" VALUE="FORM.htm">

<INPUT TYPE="hidden" NAME="-error" VALUE="FORM_error.htm">

<INPUT TYPE="submit" NAME="-New" VALUE="SUBMIT">

<INPUT TYPE="hidden" NAME="[FMP-Field:RELATED::KEY]" VALUE="[FMP-Field:MASTERKEY]">

</FORM>

By removing the line:

<INPUT TYPE="hidden" NAME="[FMP-Field:RELATED::KEY]" VALUE="[FMP-Field:MASTERKEY]">

The submit works and I get a blank record created in the related record. This still leaves me with the problem of not having the foriegn key set to relate the record. What is wrong with my code.

I had a look at the inline action tag, but don't fully understand it. - am i on the right track?

Cheers

Hal.

Link to comment
Share on other sites

Instead of...

"<INPUT TYPE="hidden" NAME="[FMP-Field:RELATED::KEY]" VALUE="[FMP-Field:MASTERKEY]">

...you need to specify the name of the related field. This never changes. It should be...

<INPUT TYPE="hidden" NAME="fieldname" VALUE="[FMP-Field:MASTERKEY]">

Note that it's not a related field because the form specifies the "related" database.

Link to comment
Share on other sites

thanks Vaughn,

I have got it all working, it is easy when you do it right!

I am having another problem with the -MailFormat variable tag in an email form. I have specified my text file. When I enter text into the text file, it displays in the body of the email as typed. However when i use a replacement tag within the text file eg. [FMP-Field:MailMessage], the body of the email is blank. I can't work it out. It is obviously processing the tag, or it would just display the tag as text.

I was trying to use the MailFmtField until I realised it is not supported by web companion 5.04 and later. Do'h!

Any ideas?

Link to comment
Share on other sites

Vaughn

Yes and Yes. I checked both of those things first. But no probs I just found the problem.....

On my mail preview page I had the tag -view as the submit button. (I just copied and pasted code from my CDML Reference DB). By changing this to -Find it resolved the problem.

Thanks again for your help. - I am slowly learning the ins and outs of CDML. Love it!

Hal.

Link to comment
Share on other sites

Not to confuse you further, but if you just want the user to click a link that does this. try this (fill in the blanks):

FMPro?-db=yourRelatedDatabaseName&-lay=yourLayoutName&-format=relatedEdit.htm&relatedKeyField=[FMP-Field:mainKeyField]&-new

This will create a new record in your related database with the key field value from you have currently. Then takes them to the relatedEdit.htm page which simply is an edit page that edits the record you just created in the related database (although as far as the web or FileMaker are concerned it isn't a related database anymore).

Link to comment
Share on other sites

This topic is 7338 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
 Share

×
×
  • Create New...

Important Information

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