If you are manually changing the field import order, they do not have matching names. Names must be exact for that to work.
If you are using a $Path variable to specify the name and location of the Excel file, You need to add a second literal file reference to the Select File dialog listed below the $Path variable. Make this a reference to a copy of your Excel file that is valid at the time you set up the Export Records Script step. Then you will be able to access the columns of the excel file, map them and the mapping order should be retained. Once you have set up the script, it's a good idea to rename or relocate that Excel file so that the $Path variable is the only valid way to reference the file. Otherwise, a bug in your script that assigns an invalid file path to the $path variable can result in the script importing from that specific copy of the Excel file.
Thanks for the reply. Am confused - here's a copy of my import script. Are you saying add another variable to below this ?
No added variable needed. and I can't see your script, though it may just be slow to appear as I happened to open this thread very quickly after you posted a response.
This thread includes an example of what I am describing: Exploring the use of a $Path Variable in Scripts
I was having problems uploading my image. can you see it now ?
It's now visible. It can take several minutes at times for an uploaded image to appear along with the text.
Where your dialog shows:
you need to change this to:
Where the second entry is a working valid path to a copy of your excel file at the moment when you are defining this script step. Just click the Add File... button and select a copy of this excel file.
My best guess as to why this is needed. When you have two or more file references in this dialog, FileMaker starts with the first one and tries each in turn until it either gets one to work to access a file or runs out of file references. At the time that you create the script step, $Path does not exist and thus is not a valid file path to a file at the time you create the script step. So you need the second explicit reference in order for the Field Mapping dialog to be able to reference an actual file while you set up the needed column to field mapping. When you run the script, $Path will exist and (hopefully) have a valid file path to your excel file and the script step will use it.
Thanks. that worked. However it creates another potential issue - I am doing this for a client. So does the second reference need to the name of their local file ?
You only need that second reference to work when defining the script step. If you read back a few posts, you'll find that I recommended moving or renaming this file once you have the script step working so that there is no chance of importing from this copy of the file by mistake due to an invalid file path being assigned to the path variable.