Record locking & scripted replace

classic Classic list List threaded Threaded
7 messages Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Record locking & scripted replace

Linda Trent
Hello all!

How do other people manage Open records? The specific circumstance that prevent the replace function from replacing where a record doesn't return a true when using Get ( RecordOpenState ) or Get ( RecordOpenCount ) and is of concern to me is when a user has a current field on their screen, but they haven't made any changes so it hasn't yet registered as Open. I have some scripted replace steps that involve potentially thousands of records so looping will just take too long to test because another user may click in an already tested record before the looping is finished.

Any ideas anybody?

Cheers
Linda

linda trent
maximums productivity

filemaker business alliance member
filemaker technical network member

m. 0418 821 186
w. maximums.com.au <http://maximums.com.au/>

professional FileMaker® developers creating order out of chaos:
identifying patterns and defining strengths

http://www.smh.com.au/business/workplace-relations/appetite-for-technology-20161004-grv15p.html 

_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Record locking & scripted replace

Danny Mack
Linda,

The only reliable way to do it is through a portal.

If there isn't already a common key between the records then get the unique ID's for all the records* and put them in a global field with a relationship to the ID. Then open the parent record and do your Replace on the related records.

If there is an error you can Revert Record in the parent and none of the changes will be committed.

*There are several ways to get the ID's for a batch of records. Among others: you can create a Summary field with the "List of" option, or you can loop through the records. There are also custom functions that do this efficiently.

Danny



> On Apr 24, 2017, at 7:28 PM, Linda Trent <[hidden email]> wrote:
>
> Hello all!
>
> How do other people manage Open records? The specific circumstance that prevent the replace function from replacing where a record doesn't return a true when using Get ( RecordOpenState ) or Get ( RecordOpenCount ) and is of concern to me is when a user has a current field on their screen, but they haven't made any changes so it hasn't yet registered as Open. I have some scripted replace steps that involve potentially thousands of records so looping will just take too long to test because another user may click in an already tested record before the looping is finished.
>
> Any ideas anybody?
>
> Cheers
> Linda
>
> linda trent
> maximums productivity
>
> filemaker business alliance member
> filemaker technical network member
>
> m. 0418 821 186
> w. maximums.com.au <http://maximums.com.au/>
>
> professional FileMaker® developers creating order out of chaos:
> identifying patterns and defining strengths
>
> http://www.smh.com.au/business/workplace-relations/appetite-for-technology-20161004-grv15p.html 
>
> _______________________________________________
> FMPexperts mailing list
> [hidden email]
> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au

_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Record locking & scripted replace

Mark Rubenstein
Danny, that’s brilliant!
Why haven’t I been doing that all these years?!

Mark

> The only reliable way to do it is through a portal.
_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Record locking & scripted replace

Darren Terry-3
In reply to this post by Linda Trent
I never use Replace in a multi-user environment. I always use a loop so that I can capture exactly which record(s) threw an error, and I can decide what I want to do about it. Looping through a found set is not appreciably slower than performing a replace on the found set, and is very much faster if you need to replace more than one field (because you can loop through the found set once and use multiple Set Field steps in the loop, whereas each Replace command loops through the found set individually).

Danny suggests using a portal, and if you need the entire Replace operation to be atomic (meaning, it’s all or nothing), that’s the way to go. But if you want the data to be replaced in every record of the found set while capturing which record(s) failed, you need to loop.

> On Apr 24,2017, at 6:28 PM, Linda Trent <[hidden email]> wrote:
>
> How do other people manage Open records? The specific circumstance that prevent the replace function from replacing where a record doesn't return a true when using Get ( RecordOpenState ) or Get ( RecordOpenCount ) and is of concern to me is when a user has a current field on their screen, but they haven't made any changes so it hasn't yet registered as Open. I have some scripted replace steps that involve potentially thousands of records so looping will just take too long to test because another user may click in an already tested record before the looping is finished.
>
> Any ideas anybody?



regards,
Darren

******************************
 Darren Terry
 Pacific Data Management, Inc.
 FileMaker Certified Developer
 Phone: (408) 283-5900 x7003
 Fax: (408) 283-5903
 [hidden email]
 http://www.pdm-inc.com/

_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Record locking & scripted replace

Bob Gossom
In reply to this post by Mark Rubenstein
Hi,

Danny’s trick is neat and easy, but the replace through the relationship will be slower than doing it directly in the table.

Looping, even through thousands of records can be surprisingly fast. The advantages of looping for the replace include having the records that aren’t locked updated, and the ability to create a log of locked records so that you can deal with them later.

The best method will likely be driven by the business rules.

Bob Gossom
Absolute Advantage, Inc.

> On Apr 24, 2017, at 8:10 PM, Mark Rubenstein <[hidden email]> wrote:
>
> Danny, that’s brilliant!
> Why haven’t I been doing that all these years?!
>
> Mark
>
>> The only reliable way to do it is through a portal.
> _______________________________________________
> FMPexperts mailing list
> [hidden email]
> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au

_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Record locking & scripted replace

Richard DeShong
In reply to this post by Darren Terry-3
Hi Linda,

And to keep looping time to a minimum, create a "utility" layout, based
on the table needed, with no fields on it.  Since there are no fields on
the layout, FM Server does not send any data to your client as it loops
through the records.  It is essentially the same as Perform-On-Server
which, btw, is another option.


On 4/25/2017 11:17 AM, Bob Gossom wrote:

> Hi,
>
> Danny’s trick is neat and easy, but the replace through the relationship will be slower than doing it directly in the table.
>
> Looping, even through thousands of records can be surprisingly fast. The advantages of looping for the replace include having the records that aren’t locked updated, and the ability to create a log of locked records so that you can deal with them later.
>
> The best method will likely be driven by the business rules.
>
> Bob Gossom
> Absolute Advantage, Inc.
>
On 4/25/2017 9:47 AM, Darren Terry wrote:

> I never use Replace in a multi-user environment. I always use a loop so that I can capture exactly which record(s) threw an error, and I can decide what I want to do about it. Looping through a found set is not appreciably slower than performing a replace on the found set, and is very much faster if you need to replace more than one field (because you can loop through the found set once and use multiple Set Field steps in the loop, whereas each Replace command loops through the found set individually).
>
> Danny suggests using a portal, and if you need the entire Replace operation to be atomic (meaning, it’s all or nothing), that’s the way to go. But if you want the data to be replaced in every record of the found set while capturing which record(s) failed, you need to loop.
>
>> On Apr 24,2017, at 6:28 PM, Linda Trent <[hidden email]> wrote:
>>
>> How do other people manage Open records? The specific circumstance that prevent the replace function from replacing where a record doesn't return a true when using Get ( RecordOpenState ) or Get ( RecordOpenCount ) and is of concern to me is when a user has a current field on their screen, but they haven't made any changes so it hasn't yet registered as Open. I have some scripted replace steps that involve potentially thousands of records so looping will just take too long to test because another user may click in an already tested record before the looping is finished.
>>
>> Any ideas anybody?
>
>
> regards,
> Darren
>
> ******************************
>   Darren Terry
>   Pacific Data Management, Inc.
>   FileMaker Certified Developer
>   Phone: (408) 283-5900 x7003
>   Fax: (408) 283-5903
>   [hidden email]
>   http://www.pdm-inc.com/
>
> _______________________________________________
> FMPexperts mailing list
> [hidden email]
> http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au

--
Richard DeShong
Logic Tools
510-642-5123 office
925-285-1088 cell

_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

Re: Record locking & scripted replace

eric scheid-5
In reply to this post by Linda Trent
On 25 Apr 2017, at 11:28 am, Linda Trent <[hidden email]> wrote:
> I have some scripted replace steps that involve potentially thousands of records so looping will just take too long to test because another user may click in an already tested record before the looping is finished.

Another technique apart from looping over all records is to set up an auto-update trigger and look  for those records that didn’t get that updated …


Define two fields:
• Scripted_Replacing (global, text)
• Scripted_Replaced (Timestamp) auto-enter by calculation
    Case (not isempty(Scripted_Replacing), Get(CurrentTimestamp))


Then, in your script do something like this:

#
# do the replace
Set Variable [$ReplacingStart, Get(CurrentTimeStamp)]
Set Field [ScriptedReplacing, “Yes”]
Replace [your_field_name, …, no dialog]
Set Field [ScriptedReplacing, “”]
#
# find the records that didn’t update
New Window
Enter Find Mode []
Set Field [Scripted_Replaced, $ReplacingStart & “…”]
Omit
Constrain Found Set []
If [Get(FoundCount) = 0]
  # all updated =)
  Close Window
Else
  # some not updated
  Perform Script [Order Beer]
  Perform Script [Cancel Life]
  Perform Script [Panic]
End If

e.
_______________________________________________
FMPexperts mailing list
[hidden email]
http://lists.ironclad.net.au/listinfo.cgi/fmpexperts-ironclad.net.au
Loading...