Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
tohor
Contributor
Contributor

FileExist checks in JavaScript extension

Hi, 

I am trying to do a FileExist check within a JavaScript Qlik Sense Extension. I have .png files in the Extension folder: i.e. ...\Qlik\Sense\Extensions\mycustomexport\lib\images\, unfortunately, I might not necessarily have every image I will try to load. I need to have a FileExist check which does not seem to work as expected.

If I load a file that exists everything works just if the file not exists the extension execution fails silently. I tried a naive JS fileexist check but this does not seem to work:

                const filesys = require('fs')
                if (filesys.existsSync("/extensions/mycustomexport/lib/images/thepng.png")) {
                    console.log("yep, I am here");
                }else{
                    console.log("nope");
                }

I am also not overly familiar with JavaScript, so I am not sure if my problem is a pure JS one or if the Qlik environment adds something that I am not aware of - referencing existing files does work, the pngs are loaded. I just can't do 'does exist' checks.

I would appreciate any pointers.

My Javascript uses below blueprint and I do the export to my file within the 'paint' block

define( [ ], function ( ) { return { paint: function ($element) { /* do my export stuff */ } }; } ); ( https://help.qlik.com/en-US/sense-developer/November2019/Subsystems/APIs/Content/Sense_ClientAPIs/ex...)

 

Labels (3)
0 Replies