- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Multifile Import in a script / workflow
What is the best way to use Multi File Import in a script?
[I want to give the user the chance to edit the settings and then click on Import.]
My current approach:
- Pause the script till the import is ready:
- use a while loop
- stop it via Set Import Callback
finished= 0; mfi = Multiple File Import( <<Set Import Callback( finished=1) ); my win = mfi << createwindow; while(not(finished), wait(1));
- get a list of the imported data tables:
via _wfb_Listdiff() (from Workflow Builder):
_wfb_ListDiff = Function( {tempOld, tempNew}, For( i = 1, i <= N Items( tempOld ), i++, For( k = N Items( tempNew ), k >= 1, k--, If( tempOld[i] == tempNew[k], Remove From( tempNew, k, 1 ) ) ) ); tempNew; ); Custom_step_tables_old = Get Data Table List(); MFI(); while(no(finished), wait()); Custom_step_tables_new = Get Data Table List(); dts = _wfb_ListDiff( Custom_step_tables_old, Custom_step_tables_new );
- if there is no data ..
To stop the execution of subsequent code, check
did you know that stop() inside a Workflow step just stops the execution of the current step?if (items(dts) ==0, Throw("no data"));
so: Throw(). -
The user can close the MFI dialog via
then the while loop will run forever (or: till the user presses ESC)
-> add an on close script:
my win = mfi << createwindow; wait(0); current window() << on close(finished=1)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Multifile Import in a script / workflow
You should be able to get the list of imported tables from the callback function, look at the SetImportCallback example.
If JSL does the <<ImportData, that also returns a list of tables. But in your case, the user presses a button and the callback is the only way to report them.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Multifile Import in a script / workflow
As an alternative, I changed the behavior of the Import button:
my win[ButtonBox(8)] << set function (dts = mfi << Import Data(); wait(0); finished=1);
But, unfortunately, the original import is triggered as well.
... so I replaced the import button with an alternative one:
my win = mfi << createwindow;
my win[ButtonBox(8)] << sib append (Button Box ("Import +",dts = mfi << Import Data(); wait(0); my win << close window()));my win[ButtonBox(8)] << delete
What example are you referring to, I couldn't find it.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Multifile Import in a script / workflow
Make sure the category selector shows objects (or all.)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Get Direct Link
- Report Inappropriate Content
Re: Multifile Import in a script / workflow
: )