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 Spidey
      Hi,
      I have two table: Invoice and Customer.  I like to have the total of all the invoice for a customer between certain date in the Customer portal that show all the customers, but I got a error when I try to debug..
      ExecuteSQL("SELECT SUM(I.TotalAmount) FROM Invoice I JOIN Customer C ON I._kf_CustomerID = C.__kp_CustomerID WHERE date(I.InvoiceDate) between date(C.SearchFromDate ) and   date(C.SearchToDate )" ; "" ; "" )
      I have an error and couldn't figure it out.  Thanks...
      KC


    • By Todd Dignan
      I have a client that has been using a send email script step  that brings up the outlook email client on the desktop.  This as worked for years no problem.  It has stopped work on 3 of 35 computers within the last two weeks.  I talked with there IT personal and they have assured me that no updates have happened.  The actual error is -
      Microsoft Office Outlook
      Either there is no default mail client or the current mail client cannot
      fulfill the messaging request.  Please run Microsoft Outlook and set it as
      the default mail client.
       
      I have double checked with system default  and Outlook's settings.  Both are set to default.
      The client is using the latest version of office 360's and the latest version of FileMaker 18 advance. Both 64bit.
      Any suggestions are welcome.


    • By tbcomputerguy
      I have an excel sheet that controls bills of ladings for a forestry company.  In the example you can see that there is lots going on with this Bill.  It has a payperiod, mill, truck that delivered it, etc.
      I would like setup a database to monitor this.  The fields CT1, CT2, Skid1, Skid2. PROC1, PROC2 are all contractor numbers.  There are 6 contactors.  The percentages in each line are the amount of the volume they performed  In the third line there is a value in CT1 only...they get 100% of the volume.  I can figure out most of this, but am stumped on how I can monitor when a contractor does multiple jobs..ie in line one, contractor 5, cuts and skids.  All 6 contractors could be involved in one BOL. Each one of these jobs, cutting, skidding and processing each has their own respective rate of pay as well.   I think i need a way to break down each line so that I can produce pay summaries for each of the contractors.  I had started this years ago, and thought I asked in a forum, but can't remember where.  Nonetheless, they stopped using multiple contractors per load...Now they have returned, so I am back at it.  So if this is a repost from years ago I apologize.  
      Thanks in Advance
      tbcomputerguy
       
       

    • By dancer5678
      I am using Filemaker Server 18 on Windows Server 2012 R2
      Been using it for years with no issues
      Currently when I log in to the console it is very sluggish.
      When I get to the Dashboard it shows No databases, then it auto refreshes and the database list appears.
      Within 15 seconds of scrolling the database list to open files the screen refreshes. This situations is happening over and over in a loop.
      Any Thoughts on what is causing this issue?
       
       
       
       
    • By stevaroni
      I get an error 3 when using a script to Export Records via WebDirect. Using FileMaker Server 18 and have tried both Safari and Chrome both with same results. I have tried using the temporary path, desktop path, and documents path. I have tried using with the automatically open and not. I have tried writing a tab delimited and comma delimited file. Does anyone have ideas I haven't yet tried?
  • Who Viewed the Topic

    10 members have viewed this topic:
    ghagen  Jack Hayward  3DSteve  moriya0238  Şemsi Saracoğlu  Rick Miller  mark_b  B.Fehr  billw  Lee Smith 

×
×
  • Create New...

Important Information

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