Skip 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.

Using Set Field

Featured Replies

Today's my day for problems. I would like to have a script that creates a new record based on a previous record. I bill my clients on a retainer basis. The record has a Jo_ID related to the Company_ID. All relationships work correctly. When I go to Retainer layout, create new record, and add the Jo_ID the company name, address etc. fields are properly filled in.

My problem is I can not get "set field" to fill in the data from the previous months record. Additionally, I have a payment number field and I need to increment that number every month. In some instance there are 2 or 3 large payments and in other instances there are up to 6 or more smaller monthly payments.

I have tried to set up a script and without using the "Copy"/"Paste" command I can not get the data into the corresponding field. I'm attaching a copy of the basic script I'm using. I have tried to do a "Let" statement, but I am very weak in this area (as well) :)

Any/all help suggestions would be appreciated.

Thanks,

Al

Create_AE_Invoice.pdf

I'm not getting everything you explain, but here is one way to dupe the current record including it's portal-stuff!

--sd

invoicing.zip

Use a global field in between.

For example the script could:

sort prev record to top

go to first record

set data to global

create new record

set global data to new record

David

  • Author

Soren:

As usual you are Spot On! Thanks for the help. again. :) Btw, last time you sent me to several sites that were very informative. Any reading suggestions for setting variables?

Appreciate suggestions from all.

Thanks,

Al

... its fairly straight forward

just use the set variable script step...

then for a global variable that can be used throughout your current database file.. define it as $$variable name and attach it to any value you want... if you want the variable to be only used in the current script... simply define it as $variable name utilizing the same script step...

either way they're pretty powerful cause you dont have to define globals everytime you want to store something for a while... they're also much quicker than globals...

genx

I agree with genx ...fairly straight forward, which means that the urge to document it as feature is next to nothing. But perhaps it helps to investigate the measures we used to went thru before $variables arrived - so we had to wrap the script inside at recursive call to grap the recordID we need in order to change the foreign key in the new records we create in the itemlines table. Downside of recursive scripting is, that they're confusing to debug.

If [ IsEmpty ( Get ( ScriptParameter ) ) ] 

     Perform Script [ “New Script”; Parameter: TheInvoice::InvoiceID ] 

Else 

     Show All Records 

     Omit Record 

     Show Omitted Only 

     Duplicate Record/Request 

     Go to Record/Request/Page [ Previous ] 

     Go to Related Record [ From table: “ItemLines”; Using layout: “ItemLines” (ItemLines) ] [ Show only related records ] 

     Go to Record/Request/Page [ First ] 

     Loop 

            Duplicate Record/Request 

            Set Field [ ItemLines::ForeignKey; Get ( ScriptParameter ) ] 

            Omit Record 

            Go to Record/Request/Page [ First ] 

            Omit Record 

            Exit Loop If [  not Get ( FoundCount ) ] 

       End Loop 

       Go to Layout [ “TheInvoice” (TheInvoice) ] 

       Go to Record/Request/Page [ Last ] 

       Show All Records 

End If 

By and large the same script, wrapped into a recursion!

But say you have enforced a strict rule that prevents any changes in a foreign key at all. It's a different topic to debate "Should the users be allowed access to any keys" ...so just lets say it's designed that way, but what we really wish to have is a duping of the invoices?

Well we can have a bit of both, recursions as well as $variables, take a look at following template, which just is an alteration of the original - But the reasoning in the script is very different. We have got rid of both the duplicate steps as well as the looping steps - but be warned you'll get into difficulties in grasping whats going on without tracing with arrow pointing right in the debugger (allowing to dig into subscripts), the dataviewer isn't amiss either!

--sd

invoicing2.zip

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

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.