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

Identify server name with a mapped drive

Hi there,

I have a need to identify the server the application lives on as part of the reload. The way we work, is we have our apps saved on our development environment and we have a process for moving them to production. 

What I want to happen is to identify which server the application is saved on during the reload so I can do something with that information. 

The problem I am having is if someone has mapped a drive to the server I am returning the drive instead of the server name. 

Here is my code:

Let vTrainingPath = '..\Documents';

For Each File in filelist ('$(vTrainingPath)'&'\*.mp4')
    Temp:
       LOAD
            TRIM(REPLACE(SUBFIELD('$(File)','.',1),'\\',' ')) AS Server
       AUTOGENERATE 1;
Next File

This works great if the user hasnt mapped the server to a drive otherwise it returns the drive letter instead of the server name. 

Any suggestions for always getting the server name? 

I looked at ComputerName() but if someone reloads using the desktop app this would break.

Labels (4)
1 Solution

Accepted Solutions
cbushey1
Creator III
Creator III
Author

For those of you reading this later, I found a solution to this.

Instead of using the File variable in the field Server, I define a variable using the system variable QvWorkRoot and use that instead. 

Here is what I am using:


Let vTrainingPath = '..\Documents';
Let vServer = QvWorkRoot;

For Each File in filelist ('$(vTrainingPath)'&'\*.mp4')
    Temp:
       LOAD
            TRIM(REPLACE(SUBFIELD('$(vServer)','.',1),'\\',' ')) AS Server
       AUTOGENERATE 1;
Next File

 

View solution in original post

3 Replies
Bill_Britt
Former Employee
Former Employee

Hi,

Qlik recommends not using Mapped Drives. Normally, service accounts have issues with this and if you someone else is trying to work with the document, their mapped drives may be different. I would recommend getting the users to change their setting to use UNC paths. 

 

Bill 

Bill - Principal Technical Support Engineer at Qlik
To help users find verified answers, please don't forget to use the "Accept as Solution" button on any posts that helped you resolve your problem or question.
cbushey1
Creator III
Creator III
Author

Hi Bill,
Thanks for the reply.
We aren't coding anything in the application with a mapped letter. Everything is relative paths. However, in my code above where I am trying to return the name of the server, if this is run locally on a machine where the drive is mapped it returns that letter instead of the server name.
The applications physically live on a development server and tied through source control so that each developer works on the same .qvw
cbushey1
Creator III
Creator III
Author

For those of you reading this later, I found a solution to this.

Instead of using the File variable in the field Server, I define a variable using the system variable QvWorkRoot and use that instead. 

Here is what I am using:


Let vTrainingPath = '..\Documents';
Let vServer = QvWorkRoot;

For Each File in filelist ('$(vTrainingPath)'&'\*.mp4')
    Temp:
       LOAD
            TRIM(REPLACE(SUBFIELD('$(vServer)','.',1),'\\',' ')) AS Server
       AUTOGENERATE 1;
Next File