Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Script to Create New Portal Record

Featured Replies

  • Newbies

Hello - I'm not a developer but have been using FMP for a long time.  I've never learned scripting but am now taking a stab (unsuccessfully as yet) at it.

My database begins with tables for "Projects" ... and these are related to "Grants" ... and these are related to "SubGrants."

From the "Projects" screen, I'm trying to create a script for a button in order to create a new "Grant."

FYI, I've been doing this for years now by simply using the portal relationships ... but I'm designing for use by others, so I'm trying to automate things a bit more so the user doesn't need to know too much about FileMaker.

Here's what I have but it doesn't return a "ProjectID" to the "Grants" table.  Let me know if you can help ... thanks in advance! John B

Set Variable [ $Set Global ID ; Value:Renewal Projects::zDCAProjectIDTemp = Renewal Projects::zDCAProjectID.pk ]

Commit Records/Requests

Go to Layout [ “HUD Grants” (HUD Grants) ]

New Record/Request

Set Field [ HUD Grants::zDCAProjectID.fk ]

Commit Records/Requests

Hi there!  Welcome to FMForums!  :smile3:

I see no purpose in the Renewal Projects::zDCAProjectIDTemp field at all.   Try this:

Set Variable [ $projectID ; Value:Renewal Projects::zDCAProjectID.pk ]

Freeze Window

Go to Layout [ “HUD Grants” (HUD Grants) ]

New Record/Request

Set Field [ HUD Grants::zDCAProjectID.fk ; $projectID ]

Commit Records/Requests

The Commit Records/Requests is not really needed since you will leave your User on the Grants layout to continue entering data, right?  If you plan on simply returning the User to the Projects layout, just add a final step:

Go To Layout [ original layout ]

If you get stuck, post back and we'll help you further.  

Notice also that, on your original Set Field[] step, you do not have a value returned.  Set Field[] requires two entries.  The first is the field to set and the second is the value to set it with, under the 'calculated result' button.

Edited by LaRetta

  • Author
  • Newbies

Hey LaRetta:

Thank much for replying to my post!  I appreciate your help very much!

I'm still having trouble getting this "Set Field" statement into the script.

Set Field [ HUD Grants::zDCAProjectID.fk ; $projectID ]

Specifically, I can't discover how to get the "; $projectID" into the script.

Again, I appreciate your help and will keep trying!

Hello from GA ... I have a nephew in Portland.  Nice place out there!

Best, John B

ps - tried to upload a snapshot from my file, but it "failed"

To attach a file, you will need to zip it.

  • Author
  • Newbies

Tks Lee

LaRetta ... Here's a zipped screen shot.  Using the "Calculation" option, all I can see to do is to type in the "; $ProjectID" ... but this returns an error.  Thanks, j

PS ... zipped file failed to upload ???

39 minutes ago, jtbassett4 said:

Using the "Calculation" option, all I can see to do is to type in the "; $ProjectID" ... but this returns an error.  Thanks, j

Just type in the expression =

$projectID

without any quotes or punctuation.

 

Side note:
Your script creates a related record without any data. I am not sure that's a good thing to do.

 

1 hour ago, Lee Smith said:

To attach a file, you will need to zip it.

You don't need to zip images. Actually, since the last update, you don't need to zip Filemaker files either.

 

Edited by comment

  • Author
  • Newbies

Thanks everyone! I really appreciate your help!

But I'm still not doing something right.  It isn't working.  The $ProjectID doesn't get established in the new table record.  Here's where I am with the script:

Set Variable [$ProjectID; Value:$Renewal Projects::zDCAProjectID.pk]

Freeze Window

Go to Layout ["HUD Grants" (HUD Grants)]

New Record/Request

Set Field [HUD Grants::zDCAProjectID.fk = $ProjectID]

Commit Records/Requests []

 

Set Variable [ $projectID; Value:RenewalProjects::ProjectID.pk ]
Go to Layout [ “HUD Grants” (HUD Grants) ]
New Record/Request
Set Field [ HUD Grants::ProjectID.fk; $projectID ]
# then go to the field in Grants to begin entering Grant information Go to Field [ HUD Grants::Type ]

Like this ... and also see attached sample file.  :-)

 

Grants.fmp12

drop that =.  The first is the field to set and the second is the value.  I'm hoping the file shows it very clearly.  Once you see it, you'll completely understand.  :-)

From Projects, set the variable with the pk of the table - in this case ProjectID.  Then go to the Grants table and set the projects fk field with the variable.

And to be sure you don't struggle further ... please see attached video.  I probably should have provided the video from the beginning.

Set Field.mp4

  • Author
  • Newbies

Hey LaRetta

Finally got it!  I hadn't realized that I needed to "Specify Target Field" and then do a "Calculated Result."  I had assumed it was one or the other.

This and I am so not accustomed to using the variable as a result of a calculation.

As I said earlier, I knew it was something I was not doing correctly.

So thanks so much to you and to others for helping me.

I've used FMP for years to manage state HUD programs.  So let me know if I can ever help you in any way!

Best always, John B

ps - I would send the file as an upload, but I am still unable to upload any type of file.  It could be the older version of Explorer that I am using (mandated by our IT department at present).  Just for grins, I may try again using a different browser.

On 12/31/2015 at 8:12 AM, LaRetta said:

Notice also that, on your original Set Field[] step, you do not have a value returned.  Set Field[] requires two entries.  The first is the field to set and the second is the value to set it with, under the 'calculated result' button.

I'm glad you got it, John.  No need to upload your file now that I can tell.  :-)

Create an account or sign in to comment

Important Information

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

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.