Jump to content

Script trigger that can set field for last matched record based on field entry


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

Recommended Posts

Hello,

I am gonna describe a scenario where total automation needed using only barcode scan, please bear with me:

I am creating operator timesheet layout for product lifecycle in list-view.

Each operator has a list of unique barcodes(printed sheet) for each production function.

Every activity(function) of print production is assigned code (barcode) that represents function type as well as operator name: For eg. if John is working on new plates function for Press he'd scan barcode 301-1 but if Marc is working on the same function , he'd scan 301-2 , Now '301' represents new plates function and number after hyphen(-) represents operator. In John's case 1 and Marc 2.

So, on the interface(list view of functions) , when an operator scans barcode of function it will set time-in field value and name of operator in their fields based on calculation from code.

I don't want STOP button for each function to set value of time-out (because it requires user interaction), rather, I want it automated.

I am looking for some sort of script trigger that runs on every new code scan and search for last record with similar operator name and set time-out value as current time in that record and set the same value as time-in for new function record. 

Thank you

 

Edited by dav1089
Link to comment
Share on other sites

**I'm writing this without any testing, so please treat this as a suggestion or push in the right direction rather than final instructions.

 

This is an old, old, old FM trick -

To retrieve the last created record, you can create a self-join relationship with reverse-chronology sort order.  The relationship will match on the operator ID.  If you were to set a field using the time-out value through that relationship, it'll pull the value you need.  

 

If the operators are scanning these multiple times per day and the FMP session doesn't shut down often or at all, then you can perhaps capture the time-out for each operator as they submit them, and set a global variable.  Then just refer to this G.V. as needed.

  • Like 1
Link to comment
Share on other sites

Hi @BrentHedden ,

I created script trigger onObjectSave for ID field but can't seem to be working :

So I created self-join relationship with operator ID as match field , but how to do Go to Record/Request to find previous record with duplicate ID .. (Do I do find record)?

I also created global to store entered operator ID and compare against self-joined occurance match field

I have done script trigger in past to find duplicate field records but , this time it is little complicated , I am also assigning value to another field.. and coming back to new record

Please help me

 

Thank you

 

 

 

 

Link to comment
Share on other sites

On 04/21/2016 at 10:48 PM, dav1089 said:

search for last record with similar operator name and set time-out value as current time in that record

I am puzzled why you need to do this duplication of data.  If every new record starts a new time period and ends the time period of a previous record with a matching value, then the end time can be got directly from the subsequent record using a relationship.

Link to comment
Share on other sites

 

3 minutes ago, comment said:

If every new record starts a new time period and ends the time period of a previous record with a matching value, then the end time can be got directly from the subsequent record using a relationship.

Sorry, how do I do it exactly? 

Link to comment
Share on other sites

Define a self-join relationship along the lines of:

YourTable::OperatorID = YourTable 2::OperatorID
AND
YourTable::SerialID < YourTable 2::SerialID

Place the start time field from YourTable 2 on your layout - it will show the end time of the current record.

  • Like 1
Link to comment
Share on other sites

1 hour ago, comment said:

Define a self-join relationship along the lines of:

YourTable::OperatorID = YourTable 2::OperatorID
AND
YourTable::SerialID < YourTable 2::SerialID

Place the start time field from YourTable 2 on your layout - it will show the end time of the current record.

This is one of the advantages of using a serial number over the new Get ( UUID ).

Link to comment
Share on other sites

On April 25, 2016 at 4:13 PM, comment said:

Define a self-join relationship along the lines of:

YourTable::OperatorID = YourTable 2::OperatorID
AND
YourTable::SerialID < YourTable 2::SerialID

Place the start time field from YourTable 2 on your layout - it will show the end time of the current record.

Yes, this is what I was trying to describe in my previous post.  Thanks to Comment for making this clearer.

Link to comment
Share on other sites

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