Jump to content
Claris Engage 2025 - March 25-26 Austin Texas ×

Script to Create New Portal Record


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

Recommended Posts

  • Newbies
Posted

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

Posted (edited)

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
  • Newbies
Posted

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"

  • Newbies
Posted

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 ???

Posted (edited)
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
  • Newbies
Posted

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 []

 

Posted
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

  • Newbies
Posted

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.

Posted
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.  :-)

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