Jump to content

Newbie: Create New Field in tab ?


Recommended Posts

Good afternoon/evening,

I have found a script which looks similar to the functionality I'd like to embed into a tab in my database, but it's not "quite" functioning correctly.

What I'm hoping to achieve is to have a field I can enter comments into, and then a button which when pressed, creates a new field. The idea is to keep every comment in a seperate field for ease of reference later. 

Pressing the button "New Comment" also creates the date to the left-hand side (would be nice to also add the current time), and also the "Delete Field" button to the right.

This is the script I discovered - but as you'll understand (better than I do), it doesn't create a new field, but does create a new record each time.

# save the current customer ID
Set Variable [ $customer ID ; Value: Dashboard::ID # ]

# Go to Communication Log tab and Create New Record
Go to Layout ["Dashboard" (Dashboard) ; Animation: None ]
New Record/Request

# Set Field to enter the comment into
Set Field By Name [ Comments::NewComment ; ]

# Go back to my original staring point
Go to Layout [ original layout ; Animation: None ]

1616059433_ScreenShot2020-08-26at3_44_29PM.thumb.png.a8aadee24076c507788f7b8196285ff7.png

 

Any guidance to modify the existing script would be very much appreciated.

Thanks

 

 

Link to post
Share on other sites
2 hours ago, St3v1e said:

a button which when pressed, creates a new field.

That is not possible. Fields cannot be created programmatically. Nor would you want to have it that way: just imagine what it would take to find a comment in a cluster of fields of unknown size. 

The correct approach is to create a new record in a related table for each comment. And there you can easily have another field for the creation timestamp (or separate fields for date and time, if you prefer).

 

Link to post
Share on other sites

I'm not really understanding this situation but I do get the idea of creating a new record and not a new field - thanks for outlining that.

However, I've created a relationship between 4 tables referencing 4 tabs in my layout - Contacts, Tab2, Tab3 & Comments. "Contacts" is the primary key, and all the others are linked back as ForeignKey's.

When the "New Comment" button is set to activate the script (which I now have working), I do indeed get a new record appear in the portal, but that's my "apparent" issue - every time I click "New Comment" it triggers a new record. 

I'm guessing it's to do with my layout referencing all 4 tables - and suspect that the "New Comment" button/record needs to show in another layout which only references the Comments table?

File attached.

 

Note Buyers Database (Rolodex) Updates copy.fmp12

Link to post
Share on other sites

A few notes, in no particular order:

Your layout shows records from the Comments table (and your portal show records from the current found set in the Comments table). That makes no sense. The layout needs to show records from the Contacts table (which you named ContactNames, for some reason), and the portal needs to show records from Comments.

You have the relationship between ContactNames and Comments defined to allow creation of records in Comments. That means you can create a new comments simply by typing into a field in the last (first empty) portal row and Filemaker will automatically make it related to the currently viewed contact. Since your script doesn't do anything other than create a new empty record, I don't see why you need it at all. A new empty portal row will always be there anyway.

In case you do want to use a script, you need to grab the contact's primary key in a variable, go to a layout of Comments, create a new record, set its foreign key to Contacts field to the variable, and come back to the original layout (the layout of Contacts with the portal to Comments).

Note that Set Field [ SomeTable::Somefield ], with no content specified, doesn't do anything (except generate an error).

 

Edited by comment
Link to post
Share on other sites
  • 2 weeks later...

Hi Comment,

Many thanks for the detailed reply - plenty of excellent guidelines there. 

Apologies also for the delay in getting back to you, but things have been very busy at work and I'm struggling to find a few hours here and there to work on this - however, this weekend is free so I'm hoping to put your advice into practice and get back to you if I have any further questions.

Thanks

Link to post
Share on other sites
  • 2 weeks later...

Hi Comment, thanks for your help, spent the weekend trying to figure this out and think Im  90% there.

I'm sure I'll be back with more questions as this DB takes shape.

Appreciate your help and guidance.

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
  • Similar Content

    • By ggt667
      Is there a way to query CWP using FMPXMLRESULT as payload to create new records in FileMaker? Goal is to be able to insert records from command line using curl from FMPXMLRESULT files to avoid a somewhat clunky query from FileMaker XML import.
      I tried the following:
      cd /tmp/ curl -X POST -kL -o /tmp/findany.fmpxmresult.xml "user:pass@127.0.0.1/fmi/xml/FMPXMLRESULT.xml?-db=PushTest&-lay=Table&-findany" curl -X POST -kL --data @findany.fmpxmlresult.xml "user:pass@127.0.0.1/fmi/xml/FMPXMLRESULT.xml?-db=PushTest&-lay=Table&-new" A new record is created, however the payload is ignored.
      Payload below FTR
      <?xml version="1.0" encoding="utf-8" standalone="no"?><!DOCTYPE FMPXMLRESULT PUBLIC "-//FMI//DTD FMPXMLRESULT//EN" "http://127.0.0.1/fmi/xml/FMPXMLRESULT.dtd"> <FMPXMLRESULT xmlns="http://www.filemaker.com/fmpxmlresult"> <ERRORCODE>0</ERRORCODE> <PRODUCT BUILD="03/16/20" NAME="FileMaker Web Publishing Engine" VERSION="18.0.4.428"></PRODUCT> <DATABASE DATEFORMAT="MM/dd/yyyy" LAYOUT="Table" NAME="PushTest" RECORDS="17" TIMEFORMAT="HH:mm:ss"></DATABASE> <METADATA> <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="name" TYPE="TEXT"></FIELD> <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="number" TYPE="NUMBER"></FIELD> <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="date" TYPE="DATE"></FIELD> <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="timestamp" TYPE="TIMESTAMP"></FIELD> <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="time" TYPE="TIME"></FIELD> <FIELD EMPTYOK="YES" MAXREPEAT="1" NAME="_global" TYPE="TEXT"></FIELD> </METADATA> <RESULTSET FOUND="1"> <ROW MODID="13" RECORDID="24"> <COL> <DATA>Sweet</DATA> </COL> <COL> <DATA>667</DATA> </COL> <COL> <DATA>06/05/2020</DATA> </COL> <COL> <DATA></DATA> </COL> <COL> <DATA>10:44:15</DATA> </COL> <COL> <DATA></DATA> </COL> </ROW> </RESULTSET> </FMPXMLRESULT> If I simply put the parameters after the "?" in the payload file it works, however INSERTing the actual FMPXMLRESULT would be desirable.
      curl -X POST -kL --data @/tmp/GETlike.txt "user:pass@127.0.0.1/fmi/xml/FMPXMLRESULT.xml" Where /tmp/Getlike.txt contains
      -dbnames as pr example returns expected list of database names.
    • By Msaeed
      Hi All,
      I would like to find solve my issue, as mentioned on the topic of how can find more than fields like serial No. or Code by IOS camera. please find below the script.
       
       
       
      thank in advance for any help or support  
    • By tomp
      I'm having a problem getting BE_SMTPsend to successfully send an email with an attachment.
      No problem sending without an attachment, but when I add an attachment, I get an error 2 (not sure exactly what that means, but without the attachment, no error)
      These are the argument strings with and without attachments:

      I have tried both relative and direct file paths for the variable $attachment. Examples are:


      Both of them return an error code of 2.
      Since the 'send' without an attachment works, all the values of the fields/variables other than $attachment must be valid.
      Can anyone offer a suggestion as to what might be going on and what I might try to resolve this?
       
    • By Msaeed
      Hi All,
      As per mentioned on topic, in fact i would like to create icon ex. hour in case rigging guard the insert time.

    • By Solvax
      Hi,
      I'm trying to make a subsummary report with data from the current table and a related table.
      I never get to display the correct totals for the related table, and would therefore appreciate your help.
      First I'll try to explain the workflow:
      I have two tables called 'Voorraad_uit' (= outgoing stock) and 'Voorraad_in' (= incoming stock) which are related by delivery number.
      Data is first entered in 'Voorraad_in' (= incoming stock) and then related records are created in 'Voorraad_uit' when an incoming stock item is partly or completely shipped.  This second table contains mainly the outgoing amount and a unique outgoing delivery ID.

      As a consequence, one record in table 'Voorraad_in' (= incoming stock) can have one ore more related records in 'Voorraad_uit' (=outgoing stock).
      I want to make a subsummary report showing the total amount of incoming and outgoing units per product(name) by using the following layout structure:

      I tried two scenarios which each give me a part of the desired result.
      when I base the layout on 'Voorraad_in' (=incoming stock): I get the right totals for incoming deliveries I get all the incoming deliveries listed (also those without outgoing delivery) Body part 3 (see above) only shows one row also when there are more than one related outgoing transactions I get the wrong totals for outgoing deliveries (only based on one record) when I base the layout on 'Voorraad_uit' (=outgoing stock): I get the wrong totals for incoming deliveries I don't get all the incoming deliveries listed (only those with outgoing delivery) Body part 3 (see above) shows all the related outgoing transactions I get the right totals for outgoing deliveries Main goal is having the right totals for both incoming and outgoing deliveries..
      My layout is sorted ascending by (in mentioned order) productname, incoming delivery number and outgoing delivery number.
      The totals are calculated by using summary fields.
      I hope I'm on the right track and that the desired result is possible.. your help is much appreciated!
      Thanks in advance for your help.
      Regards,
      Solvax
  • Who Viewed the Topic

×
×
  • Create New...

Important Information

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