Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Pulkit_Thukral
Partner - Creator II
Partner - Creator II

How to run a task in QMC on placing of an excel file in a local folder

Task in QMC should automatically start running as soon as someone places a particular excel file in a local folder.

How can this be achieved ?

1 Solution

Accepted Solutions
marcus_sommer

One possible reason are the wrong fieldnames mentioned already from Anil. Another is the missing second/third parameter from the peek-function which are necessary if the function is used outside from a load-statement. The default-behaviour for this case isn't documented anywhere - I think it takes the value from the last loaded table but I'm not really sure - this meant it's always better to set them explicitly, like:

let v_OldDate=peek('Filetime_Old', -1, 'Table1')

Beside this I would rather not use num() in this case and if I wouldn't use single-quotes around the variables by comparing them - just: $(v_OldDate) because the content is numeric - whereby I didn't think that this is related to your problem.


To see which values are really within the variables use some trace-statements like:


trace $(v_OldDate);


and/or run the script within the debugger and/or take a look within the script-log.



Independing of the above mentioned things I would compare the filetimes directly like:


if FileTime(Incremental.xls) <> FileTime(Old_Data.qvd) then

     // this

else

     // that

end if

- Marcus

View solution in original post

9 Replies
marcus_sommer

You could create a qmc-task which checked per filetime() - directly or within a filelist-loop - if the file exists respectively has changed and which might be triggered to 1 minute. The (un)successful run of this task could trigger your origin task.

If something like this isn't suitable you will probably need an external batch/routine to monitor the folder and to trigger an external qmc-task maybe per Using EDX in QlikView 11 - basic example.

- Marcus

Pulkit_Thukral
Partner - Creator II
Partner - Creator II
Author

Marcus,

i was working on the first solution as provided in your comment.

But i am facing some issue while comparing both the date variables.

Below is my script :-

Table1:

Load num(Filetime_Old) as Filetime_Old

from Old_Data.qvd;

let v_OldDate=peek('Filetime-Old')

Table2:

Load num(FileTime() ) as Filetime_New

from Incremental.xls;

let v_NewDate=peek('Filetime-New')

if '$(v_NewDate)' <> '$(v_OldDate)' Then

Drop Table Table1;


ELSE

Drop Table NONExistingTable;


ENDIF


In current Scenario, v_NewDate and v_OldDate are having exactly same values but still if case is being loaded rather than choosing else case.

What could be the issue here ?

Format is same for both fields.

Anil_Babu_Samineni

Seems you made mistake here

let v_OldDate=peek('Filetime-Old')

let v_NewDate=peek('Filetime-New')

Field Name must be placed as wrong. Try Filetime_Old instead of Filetime-Old

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Pulkit_Thukral
Partner - Creator II
Partner - Creator II
Author

It's actually Filetime_Old and Filetime_New .

By Mistake, wrote it like other way.

marcus_sommer

One possible reason are the wrong fieldnames mentioned already from Anil. Another is the missing second/third parameter from the peek-function which are necessary if the function is used outside from a load-statement. The default-behaviour for this case isn't documented anywhere - I think it takes the value from the last loaded table but I'm not really sure - this meant it's always better to set them explicitly, like:

let v_OldDate=peek('Filetime_Old', -1, 'Table1')

Beside this I would rather not use num() in this case and if I wouldn't use single-quotes around the variables by comparing them - just: $(v_OldDate) because the content is numeric - whereby I didn't think that this is related to your problem.


To see which values are really within the variables use some trace-statements like:


trace $(v_OldDate);


and/or run the script within the debugger and/or take a look within the script-log.



Independing of the above mentioned things I would compare the filetimes directly like:


if FileTime(Incremental.xls) <> FileTime(Old_Data.qvd) then

     // this

else

     // that

end if

- Marcus

Pulkit_Thukral
Partner - Creator II
Partner - Creator II
Author

I started with the solution as mentioned in last part of your reply but was not sure if

FileTime(Old_Data.qvd)  will provide time of QVD Creation or source xls file.


Let me try this and confirm you back.

Pulkit_Thukral
Partner - Creator II
Partner - Creator II
Author

If i am not using single-quotes around the variables in if statement ,then below error is coming,

neither it reads right side value nor it provides a proper result.-

Capture.PNG

marcus_sommer

Yes the right part returned NULL - I think that the path and/or the filename aren't quite correct - it should look like:

filetime('FullPath\FileName.FileExtension')

- Marcus

Pulkit_Thukral
Partner - Creator II
Partner - Creator II
Author

Thanks for providing your inputs.

Right side was coming null only in variable but not if loaded directly.

I just wrote max() while loading it and it worked somehow.