3 Replies Latest reply on Jul 25, 2015 3:37 PM by philmodjunk

    Scripted import routine



      Scripted import routine


      Hi there

      I've built a script to assist with importing records which works well.  

      The only issue is the import dialog itself, where you need to match source to destination data.

      I currently have the script set to 'show dialog' so I can see what's going on - eventually I'll hide this so users don't get confused.

      The problem with the dialog is that the fields always reset to a default position, ie, not how I arranged them on the last import - even if I tell it to use the last import setting.

      How can I get these fields to 'stay' - my import files will all be of one standard, I'd like the mapped fields to stay matched to this standard and be hidden from the user so it appears seamless.



        • 1. Re: Scripted import routine

          will the users need to select the file from which to import or will it be named identically and always in the same location?

          I can describe one method that imports from the same name/location each time and one that allows the user to select the source file from any location that they can access.

          • 2. Re: Scripted import routine

            Hi Phil

            The users will be selecting a file from anywhere, yes.  They would have put a header on it, made sure it's a suitable Excel format on saving, but that's all.  This is a light touch routine :)




            • 3. Re: Scripted import routine

              The trick is to set up a container field--it can be a global field on a layout with Insert File as the script step to ask the user to select a file and with the "store a reference" option specified. This action stores a reference to the selected file in the container field. Your script can then use:

              Set Variable [$Path ; GetValue ( YourContainerFieldHere ; 2 ) ] to extract that file path from the container field.

              You can then use Import Records with this $path variable in order to import records from it. The key trick is to set up a two row file reference where the first row refers to a sample excel file you have in place just so that you can set up the column to field mapping needed for the import. The second row is just $Path.

              When you set up the import records script step it refers to the first file reference and you  are able to set up the mapping dialog. When the step executes, the reference to the first file should no longer be valid (remove or rename the file if necessary) and the system uses the second row, the $path variable to determine which file to use for the import.

              For more on $Path variables, container fields and the script steps that can use them, see: Exploring the use of a $Path Variable in Scripts