Jump to content

Filter records to sync


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

Recommended Posts

Forgive the 'doh' question but I am just exploring whether Mirrorsync will fit with requirements....

We currently have a sync process which runs well but does not process records quickly enough and we can sometimes have users needing to sync 10k+ records (I won't bore you with the 'why?' now :-)

We have iPads out on location with one or more users and there may be more than one person who may need to use a single iPad and thus there may need to be a filter applied to the sync process to only work with data which the current user is cleared to 'see'

In our current sync incarnation, we have rolled our own login which queries the remote server - if online - and returns the PK to be filtered back to the iPad and then we can use this filter in the queries that we run on the remote FM data to limit the datasets to be synced

Can MirrorSync provide similar filtering possibilities ?

Please feel free to ask questions of me as I know that this is probably a more complex process which I have wrapped up in a few lines of forum post :-)

Cheers

Harry

 

Link to comment
Share on other sites

Unless someone has further information to add, I think that my question was answered by this post:

The title did not help but I did scan the content and the thread veered off in the direction of syncing a custom dataset

Cheers

Harry

Link to comment
Share on other sites

Hi Harry - yes, be sure to read this section of the documentation on customizing found sets per-user:

http://docs.360works.com/index.php/MirrorSync_advanced_topics#Customizing_MirrorSync

One thing to be careful about - if you have multiple users sharing the same iPad, I would recommend having a separate copy of file on the iPad for each user. Otherwise, it will insert and delete records from your offline file each time a different user access the iPad in order to get the correct record set for that user. It's much more efficient to have one file for each user, so that MS is not having to insert/delete each time.

Link to comment
Share on other sites

Hi Jesse

Thanks for your reply

Logistically, the management of separate solution files might be a 'bridge too far' for the users :-)

That said, maybe I can put the appropriate filters in the solution file itself which will handle the found sets that may need to be worked with

I'll ruminate on that one and get back to the forum if any problems rear their ugly heads

Cheers

Harry

Link to comment
Share on other sites

It will work OK for multiple users to share a single iPad - just be aware that it is not efficient, because if each user is supposed to have access to different record sets, MirrorSync will need to insert / delete records from the offline database so that the currently logged in user only has access to their own records.

If there is some other way you'd like to see this working, let me know.

Link to comment
Share on other sites

  • 2 weeks later...

We have been trying to amend the MirrorSync Customisation script and have been failing to get the necessary results

The premise is that currently the sync needs to go one way - from the HUB to the SPOKE

The filter needs to be applied to each of the tables that we need to sync records for and that filter is contained in a $$tour variable

This variable has one or more values in it as a list and we extract each value and create a find request for it and then constrain the found set

This process is followed for each of the tables as part of a large 'If - Else If - End If' which tests for the layout name and runs the find - see the screenshot of part the script amendment attached as the construct shown is simply replicated further in the script

Are we doing anything stupidly wrong here ?

Cheers

Harry

image.png

Link to comment
Share on other sites

You can't use $$doubleDollar global variables in the script, because it's running server-side with no user session.

This is documented in the comments in the customization script about one inch higher than the top edge of your screen shot.

The solution is to do whatever find you need to populate the variable, instead of relying on the global variable being already set when the script is run.

Link to comment
Share on other sites

Always a simple answer when you look closer - I must get my eyes tested :-)

Thanks for the superfast reply, Jesse

Cheers

Harry

Edited by Harry Catharell
Link to comment
Share on other sites

Hi Jesse,

I am working with Harry on the same project - thank you for your help so far. Unfortunately, we are still having problems. 

As suggested, I have changed our code to set a local variable within the customisation script in order to filter the records we would like to sync. I have done this by using the account name the user has logged in with to find our list of keys. 

In the testing I have been conducting, I log in with account name 'stairslewis' in both the spoke and hub. Using the find request in the image attached, the $tour_list variable would contain only '925' (though, in theory, could be a return-delimited list of numbers). The script should then go through the rest of the tables to filter the _fk_tour field on this value of 925.

 

While debugging the customisation script, I noticed that the 'Set Field []' script step is failing (i.e. the field is left blank) but there is no FileMaker error coming back from this script step. This is the same for all layouts, and the field is set to allow entry in Find Mode. I have tried creating a new script with only the 'Enter Find Mode []', 'Set Field []' and 'Constrain Found Set []' script steps in and the field is set correctly and the constrain works?!

Using the script above, the spoke still synchronises all records at the hub file - with the exception of 1 table. Our 'attachment' table does not receive all records at the hub, but I think this may be due to the fact it has a multi-line key - are multi-line keys a problem for MirrorSync?

Any more help you can give us would be greatly appreciated.

Cheers,

Lewis

 

 

Capture.PNG

Edited by Lewis Stairs
Wrong images
Link to comment
Share on other sites

Hi Lewis - the problem is not immediately evident from the screenshot. We could work on troubleshooting this if you want to send us a copy of the file and an export of your MirrorSync configuration, but since this is related to customization, we would need to bill for our time ($165/hour). If it turns out to be due to a bug in MirrorSync (I don't think that's likely based on the type of trouble you're having), there would be no charge.

I did notice a few things that I wanted to point out:

* It might hurt sync speed to do the find and set $tour_list on every call to the MirrorSync customization script. This script gets called fairly often, so it's a good idea to only do time consuming operations inside an if statement dependent on the relevant layout.

* I would restructure your loops so that the exit loop check happens before the set field. This is a general best practice; currently your script will do unexpected things if the $tour_list variable is empty (I suspect that may be happening); by first comparing $count and $max before setting the field that will help avoid that.

Link to comment
Share on other sites

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