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

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

Recommended Posts

Posted

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

Posted

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

Posted

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

Posted

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

Posted

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

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