Jump to content

Using Set Field

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

Recommended Posts

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.




Link to comment
Share on other sites

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


Link to comment
Share on other sites

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 ] 


     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 ] 


            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!



Link to comment
Share on other sites

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