Can you please suggest the exact use of merge field and merge variable in Filemaker ?
Merge Field are fields that you can put on a layout for information. You can not change data in a merge field. They are for example very good on layouts for printing.
Merge Variables are variables that you put on a layout. You set them through scripts and then show the value in your layout.
Does the merge variable acts as local or global variable ?
Variable is always Variable no matter if they are Global Field Variable or Merge Variable. They act over your entire solution and have one set for each user, meaning each user have there own set of Global Variables and Merge Variable. If User 1 change Value in Global Variable Field called City to "London", it is not changing the value for User 2.
You should read the free FileMaker Training Series
The merge variable is whatever variable type you declared when you defined the variable.
If you put <<$var>> on the layout it is a local variable.
If you put <<$$var>> on the layout it is a global variable.
Generally you would be using global variables if you are putting them on a layout.
In my solutions, I use merge fields only when I need to merge the data with layout text and/or other fields so that the info "flows" into seamless whole.
Welcome <<first name>> <<last name>>, today is..
Welcome John Smith, today is..
I do not use them if I only need to put read only data on my layout as I can use field behavior in the Inspector to control such access.
There are two issues with merge fields and variables to keep in mind:
1) While you can use the Inspector to set up data formatting for a block of text that contains merge objects, you can only select one format for each data type and this format is then applied to all merge objects in the text block that contain data of that type.
Example: You might have a text block with 3 numbers, two dates and one timestamp. You can select a number, date and time format for the the text block. But all three numbers get the same number format, and the two date and one timestamp all get the same date format. This can require you to put a calculated format into a merge field or variable in order to get different formats for merge objects with data of the same type.
2) The added <<merge brackets>> increase the width of your block of text and can make it difficult to fit the text within the boundaries of a normal button or portal row. There are at least two ways to get the text to fit, but both make the resulting text difficult to impossible to read while in layout mode.
This is why I use a single-button button bar for calculated text on the layout. It's a lot more flexible and controllable than a text block merge field.
Yes, I am aware of that and it's a good option. Technically, you are then no longer using a merge object as you just treat the field or variable as a calculation. I just had to draw the line somewhere as to where to stop typing. ;-)
Retrieving data ...