Jump to content

How to send value list to server


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

Recommended Posts

Hi,

In order to use the ES_Exclude fonction, I need to send some value list to the server for the calculation. (I am filtering the customers according to 2 lists : department and job ). 

Is there anybody who can explain how to send these list to the server ? I think I can't use the $$additional_pull_info because the list items are separated with carriage return right ?

Btw can we have a debug mode for the the server scripts ?

thanks and have a good day !

Jonathan

Link to comment
Share on other sites

The settings portion of the payload, which includes any additional info you send, is delimited by the end tag "</setting>", not by carriage returns. My hunch is that your value lists should work as is. Have you tried including them and seeing if the sync works?

If that proves problematic, why not change the value list delimiter to a different character which you could parse?

And... there are debug steps built into the server scripts, but you need to change the "$$use_psos_during_*" settings in the client-side settings script to 0 so that the server scripts run on the local machine.

Link to comment
Share on other sites

Excuse me Joshua, I am not sure to understand what you mean about the end tag "</setting>".

For example I saw that the the exclude action was done in the "Prepare Payload for Client" script. I can see that the parameter script is : 

Evaluation ( "EasySync_Payloads::ES_Last_Pull_UTC_Time" ) & ¶ & 
Evaluation ( "EasySync_Payloads::ES_Last_Push_UTC_Time" ) & ¶ & 
Obtenir ( IDPersistant ) & ¶ & 
$$client_version & ¶ & 
Substituer ( Obtenir ( AdresseIPSystème ); ¶; ", " ) & ¶ & 
Substituer ( Obtenir ( AdresseNICSystème ); ¶; ", " ) & ¶ & 
Obtenir ( PlateformeSystème ) & ¶ & 
Obtenir ( VersionSystème ) & ¶ & 
Obtenir ( Appareil ) & ¶ & 
Obtenir ( ProtocoleRéseau ) & ¶ & 
Obtenir ( TypeRéseau ) & ¶ & 
$$additional_pull_info

 

What am I supposed to input in the $$additional_pull_info ?

1st list & "</setting>" & 2d List "</setting>" ?

 

Link to comment
Share on other sites

First of all, "Prepare Payload For Client" is part of the PULL process and therefore not relevant to the PUSH procedure. You originally asked about sending additional information to the server so I'll address that. (Let us know if you also need to send additional info back to the client.)

On second look, I think you're right that ¶ won't work in your additional_push_info variable. This is because in "Process Payload From Client", the server replaces every "</setting> end tag with "¶" and then uses GetValue to parse the different settings including the additional info. If your value list has ¶ characters in it, the script will only grab the first value of the first value list : /.

Sooo, I think the best way to handle this would be to take both value lists and substitute a different character/string for every carriage return before putting it into the $additional_info variable. Make sure to use a string that you know won't appear in your value lists, e.g. $$additional_push_info = Substitute ( <value list 1> & ¶ & <value list 2> ; ¶ ; "¥" ). Or you can employ Tim's html-esque method and use "</vl>".

Then, in "Process Payload From Client", to convert back to value list format, change the calculation in this script step: Screen Shot 2016-08-21 at 2.12.03 AM.png

to

Substitute (

GetValue ( Substitute ( $settings ; "</setting>" ; ¶ ) ; 12 ) 

; "¥" ; ¶ )

Your $additional_settings variable should now read as your two value lists originally did back to back, separated by ¶. If you want to keep the two lists separate, use a different separator in the $$additional_push_info step.

Oh, haha, right when I finished. Glad you got it working!

Link to comment
Share on other sites

It bugs me that the "Process Payload From Client" script was substituting "</setting>" delimiters with ¶. This diminishes the usefulness of the delimiter in the first place, and instead of only having to worry about "</setting>" appearing in our data we also have to worry about any stray ¶s. ¶ is MUCH more common than "</setting>".

So I changed the script to parse the $settings variable without substitution. Just 2 steps.

       1. In "Process Payload From Client", add the following before the Set Variable [$field_delimiter] step:

Set Variable [ $i ; 0 ]

       2. Then for each of the following 12 Set Variable steps, from $field_delimiter to $additional_settings, change the calculation to:

Let ( [

$i = $i + 1 ;

$start = $end + 10 ;

$end = Position ( $settings ; "</setting>" ; 1 ; $i ) ;

$end = If ( $end = 0 ; Length ( $settings ) + 1 ; $end )

];

If ( $i ≠ 1 ; Middle ( $settings ; $start ; $end - $start ) ; Left ( $settings ; $end - 1 ) )

)

Hopefully that saves someone a future headache.

J

Link to comment
Share on other sites

Or for simplicity:

1. Set Variable [ $expression ; 

" Let ( [

$i = $i + 1 ;

$start = $end + 10 ;

$end = Position ( $settings ; \"</setting>\" ; 1 ; $i ) ;

$end = If ( $end = 0 ; Length ( $settings ) + 1 ; $end )

];

If ( $i ≠ 1 ; Middle ( $settings ; $start ; $end - $start ) ; Left ( $settings ; $end - 1 ) )

) "

]

2. Set Variable [ $i ; 0 ]

3. Change each of the following 12 set variable calculations to 

Evaluate ( $expression )

Edited by Joshua Willing Halpern
Link to comment
Share on other sites

Hi Joshua,

I think I don't really understand the way to use this exclude fonction.

I thought that the exclude process was during the “Prepare Payload for Client" because of this :

"#Add this table's fields to the SELECT statement.

#Note: This is the SELECT statement that is used to select the data for the payload.

#You can add your own custom business rules here to determine what data is sent to the user, by looking at things like the table name being worked on, the user / device that has requested the data, etc. Dynamically add your conditions to the WHERE clause."

 

So I use the $$additional_pull_info, then edit the “Prepare Payload for Client" script to get back my value list in a global variable to do the ES_Exclude calculation. But I must admit that I have some strange results...

 

Now I understand that you are talking about the "Process Payload From Client" script, and I was surprised because I thought this script was not include in the exclude process. Can you please confirm which scripts are used for this exclude fonction and need the $$additional_settings ?

 

I also have another little question : if a user make a mistake and delete a record. This record will not be pulled after that if the ES_Device_ID was this user_device. Is there any way to prevent about that ? 

 

Thanks a lot

 

 

Link to comment
Share on other sites

It sounds like your ES_Exclude calculation is not working. If you're trying to exclude records that match the value lists, maybe use the calculation: PatternCount ( $additional_settings ; <field> ) > 0. It would help to know what you specifically need.

As for the accidental deletion problem. You need to ensure your users don't accidentally delete things without logging the deletion in a payload record. If that means removing delete from the menu, then do that. To get around the ES_Device_ID problem I changed the field calculation to include either the system or host ip address depending on whether the user has accessed the local or hosted file. I had to modify the scripts to accommodate this change and prevent round-tripping. That's a subject for another thread though.

 

More about exclusions; there are 2 ways to exclude records from the sync.

1) Use the ES_Exclude field. Any record with an ES_Exclude value that evaluates to true will be excluded from the push or pull payloads. You can see that in the Push Payload script here:

Screen Shot 2016-08-22 at 2.56.30 AM.png

2) The second way to exclude records is by modifying the $dyn_sql SELECT statement in "Prepare Payload For Client."

Modify this however you want. Want to exclude all Georges from the Pull?... Add "AND name <> 'George'" to the end of the SELECT statement. To exclude values that match your value list, maybe create a loop that adds a clause each time -- E.g. & " AND field <> " & GetValue ( $additional_info ; $i )" is added with each loop. You could technically add more conditions to the Push Payload SELECT statement too, but It's probably better to push all new/edited records and only pull what you need.

J

Screen Shot 2016-08-22 at 3.15.04 AM.png

Edited by Joshua Willing Halpern
Link to comment
Share on other sites

Hi Joshua,

I think I am missing something, I run the pull script in debug mode, without PSOS, and the ES_Exclude calculation looks ok but all my records are deleted ...

Here are the client and hosted files, can you tell me what is wrong ?

Jonathan

FM_Surveys_Mobile_jMod3.fmp12

FM_Surveys_Hosted_jMod1.fmp12

Link to comment
Share on other sites

Hey Jonathan,

DELETIONS

The reason your records are being deleted is because Sync check will also exclude records with the ES_Exclude flag. In your case, to fix this you'll need to update $$additional_sync_check_info in the client settings to include your state list. In the server-side sync check script set the $States_Selected variable again so that the ES_Exclude flags are correct when the server uuid list is assembled.

1. Copy the calculation from $$additional_pull_info into $$additional_sync_check_info.

2  then add this line to the server sync check script: Set Variable [ $States_Selected ; Substitute ( $additional_sync_check_info ; "-" ; ¶ ) ] after the line Set Variable [$additional_sync_check_info]

 

EXCLUDE

Your ES_Exclude seems to be working to me. Try this: Select a state or two in your global picker. Then click the utilities button at bottom and wipe and reset. Your client db should be empty now. Click sync and the records that are pulled down should only be from those two states.

That's how your ES_Exclude is currently setup. Records that don't match your selected states will be excluded during pull.

Link to comment
Share on other sites

Hi Joshua,

When do your recommandation the "EasySync Settings Client" close the script after the line : #If there are no UUIDs in the sync tables...

So I don't achieve the Server Sync Check Process

Any idea ?

Link to comment
Share on other sites

Why don't you want to run sync check? If a record is deleted on server, it won't be deleted from client without sync check. 

Maybe I misunderstand your question?

Why don't we continue via email. Look in the easysync scripts for my email or message me directly. 

Edited by Joshua Willing Halpern
Link to comment
Share on other sites

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