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

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

Recommended Posts

Posted

I'm looking to place a button on a layout whereby it causes a given field to be filled with the value entered in the corresponding field from the previous record.

e.g. I'm creating a new record for a client's consult notes, and the 'notes' field for the previous visit(record) need to be carried over to the current entry. This is not always the case, hence I don't want it to be copied over automatically when a new record is created. Hence a "Copy Previous" button will give me the option.

Struggling with figuring out the right expression/s to use to build the appropriate script for the button. 

Any thoughts?

 

Posted

At it's simplest, the below

I'd probably abstract it a bit so I could pass in the required field via ScriptParameter so it could be used for many fields

Screen Shot 2016-02-23 at 11.03.10 am.png

  • Like 1
Posted
9 hours ago, webko said:

At it's simplest, the below

I'd probably abstract it a bit so I could pass in the required field via ScriptParameter so it could be used for many fields

 

Thanks for that Webko - I'll give that a shot tomorrow and see how it goes.

Posted
10 hours ago, db_tragic said:

the value entered in the corresponding field from the previous record.

We need a better definition of "previous record". It could be the previous record in the current found set, using the current sort order - in which case the value is accessible through the GetNthRecord() function, or by going to the previous record (as suggested above) - or it could be the previous record in creation order - in which case you would need a relationship to access it reliably.

Posted
4 minutes ago, comment said:

We need a better definition of "previous record". It could be the previous record in the current found set, using the current sort order - in which case the value is accessible through the GetNthRecord() function, or by going to the previous record (as suggested above) - or it could be the previous record in creation order - in which case you would need a relationship to access it reliably.

It is the previous record in the current found set, sorted by date (descending).

Posted
7 minutes ago, db_tragic said:

It is the previous record in the current found set

Well, then a single-action button, set to:

Set Field [ YourTable::Notes ; GetNthRecord ( YourTable::Notes ; Get ( RecordNumber ) - 1 )

should do just fine.

  • Like 1
Posted
On 23 February 2016 at 8:43 PM, comment said:

Well, then a single-action button, set to:


Set Field [ YourTable::Notes ; GetNthRecord ( YourTable::Notes ; Get ( RecordNumber ) - 1 )

should do just fine.

Thanks for that comment - haven't got round to applying suggested solutions as yet. That does look like a tidy one though, thankyou.

Posted
On 23 February 2016 at 8:43 PM, comment said:

Well, then a single-action button, set to:


Set Field [ YourTable::Notes ; GetNthRecord ( YourTable::Notes ; Get ( RecordNumber ) - 1 )

should do just fine.

Worked a treat,

Thankyou.

  • 4 months later...
Posted

OK, so I want to expand on this script a little further now.

Scenario: Each record (in a found set) has over 25 fields. 

Objective: To copy over the values of all of these (N - 1 record)  fields into the current (typically a new) record.

Question: Instead of applying the suggested script line(below) for each field, is there an expression that will allow me to copy all fields over in one go? I'm just hoping for something shorter and tidier than having to retype this for each field.

Set Field [ YourTable::Notes ; GetNthRecord ( YourTable::Notes ; Get ( RecordNumber ) - 1 )
Posted (edited)
38 minutes ago, db_tragic said:

is there an expression that will allow me to copy all fields over in one go?

Copy yes, paste no.

Is it really necessary to duplicate the contents of 25 fields? In a typical scenario, common/recurring data is held in a parent table (Clients?) and the child table (Visits?) would have fields that describe one specific child only.

 

Edited by comment
  • Like 1
Posted
On 12 July 2016 at 10:19 PM, comment said:

Copy yes, paste no.

Is it really necessary to duplicate the contents of 25 fields? In a typical scenario, common/recurring data is held in a parent table (Clients?) and the child table (Visits?) would have fields that describe one specific child only.

 

Unfortunately duplication is necessary - I work in healthcare, and the growing regulatory environment dictates a lot of information to be recorded each consult. Much of the data is very similar from one visit to the next, however some of the data isn't, so easier to duplicate the previous visit, and alter the variable data as needed. 

As it is, I realised when driving home after my post, that a catch-all copy/past would be problematic, as it would include primary and foreign keys also which would be unique to the previous record. As it is, I think I have found a better solution by creating a 'summary' field, which is built on other field contents in the record and just copy that over into the new record. 

Thanks for the input. :)

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