Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Save $650 on Qlik Connect, Dec 1 - 7, our lowest price of the year. Register with code CYBERWEEK: Register
cancel
Showing results for 
Search instead for 
Did you mean: 
Thomas23
Contributor III
Contributor III

Delete multiple users

Hello,

I want to delete multiple users from Qlik Cloud Analytics.

There are check boxes left of the user names and I can select the users but there is no delete button or something similar.

I only can delete a single user by clicking the three dots at the right and then select "Delete user" in the menu.

Is there a way to delete multiple users?

Thank you

Thomas

 

Labels (2)
1 Solution

Accepted Solutions
hugo_andrade
Partner - Specialist
Partner - Specialist

Nice @Thomas23 !

I'm happy it helped.

You can only delete one user at a time with the command, but you can stack them to run in sequence.

You can use Excel to format the sequence of calls. Copy all of them and paste at once on Command Line.

Each line will execute the user removal, and automatically proceed to the next one.

See example:

hugo_andrade_0-1756754155360.png

Then you copy the resulting column into Command Line and let it do its magic.

Please like and mark as solved if this helps you.

Thanks!

Live and Breathe Qlik & AWS.
Follow me on my LinkedIn | Know IPC Global at ipc-global.com

View solution in original post

7 Replies
stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi @Thomas23 

Depending on the number of users and how frequently you need to delete in bulk, you might want to explore the APIs available in Sense to carry this out.

This code snippet shows looping around a number of users in a load script and deleting each of them:

// Loop for each of these licences and delete them
for iOrphan = 0 to NoOfRows('Licences') -1
	let vSubject = replace(peek('Subject', iOrphan, 'Licences'), '\', '\\');
    
    // Connect to the POST connection
    LIB CONNECT TO 'Data:GenericPOST';

    let vURL = 'https://$(vInstance)/api/v1/licenses/assignments/actions/delete';
    
    TRACE ***** Removing user $(vSubject);
    
    Deleted:
    SQL SELECT 
        "type",
        "subject",
        "status",
        "code",
        "title"
    FROM JSON (wrap off) "data"
    WITH CONNECTION (
      URL "$(vURL)",
      HTTPHEADER "Authorization" "Bearer $(vAPIKey)",
      BODY "{""delete"":[{""type"":""analyzer"",""subject"":""$(vSubject)""}]}"
    )
    ;
next

 

The pull of what all the user subjects are can come from the API also.

You might find this article useful:

https://community.qlik.com/t5/Official-Support-Articles/Delete-Qlik-Cloud-licenses-using-the-REST-co...

Hope that helps,

Steve

 

Thomas23
Contributor III
Contributor III
Author

Hi Steve,


Thanks for your reply.
The reason behind my question is that I am testing the migration of users to the cloud using the migration tool. That's why I want to delete all users except the admins.
I'm not yet particularly familiar with the API, and I think the quickest and easiest way would be to select users and delete them with a single click, as you can do with apps or data connections.
But this option is obviously not available.
Or can it be configured?


Best regards,
Thomas

stevedark
Partner Ambassador/MVP
Partner Ambassador/MVP

Hi @Thomas23 

Your use case is a bit different to mine (clearing redundant licences when the user has been removed from the directory), but this part of the code may be useful also. This lists all users from the API:

// Get a list of the current users
let vURL = 'https://$(vInstance)/api/v1/users?limit=100' ; //&status=invited%2Cactive%2Cdisabled%2Cdeleted';
let iPage = 0;

do while len(vURL) > 0 and iPage < iBackstop
	let iPage = iPage + 1;
    
    TRACE ***** Fetching User Page $(iPage);
    
    JSON:
    SQL SELECT 
        (SELECT 
            (SELECT 
                "href"
            FROM "next" FK "__FK_next")
        FROM "links" PK "__KEY_links" FK "__FK_links"),
        (SELECT 
            "id",
            "status",
            "subject",
            "email"
        FROM "data" PK "__KEY_data" FK "__FK_data")
    FROM JSON (wrap on) "root" PK "__KEY_root"
    WITH CONNECTION (
      URL "$(vURL)",
      HTTPHEADER "Authorization" "Bearer $(vAPIKey)"  
    )
    ;

    // Append raw data to temporary table
    tmpUsers:
    LOAD
        id,
        status,
        subject,
        email
    RESIDENT JSON
    WHERE NOT IsNull(id);

    tmpPage:
    LOAD href RESIDENT JSON WHERE NOT IsNull(href);
    
    DROP TABLE JSON;
    
    // Next page URL, will be blank if all data fetched
    let vURL = peek('href', -1, 'tmpPage');
    DROP TABLE tmpPage;
loop

 

You will want to put a where statement in there to remove the admins. I don't know how many you have, but just a where match(email, 'joe.bloggs@acme.com', 'jane.doe@acme.com') = 0 would do it if you have a finite list.

The API call I put before was removing the licence from a user, rather than deleting from the directory. This might help if you actually want to delete them from the directory:

https://qlik.dev/apis/rest/users/#delete-api-v1-users-userId

Hopefully you will piece something together from these fragments to achieve what you need to.

It kind of feels like something that others will have done if they are using the migration tool.

Cheers,

Steve

 

 

hugo_andrade
Partner - Specialist
Partner - Specialist

Hi @Thomas23 ,

I use the Qlik CLI for it.

It a simple command line that you'll need to run.

  • Install Chocolatey: https://chocolatey.org/
  • Install Qlik CLI: choco install qlik-cli
  • Connect to your Qlik Cloud tenant: qlik context init
  • List the users: qlik user ls
  • For each user you want to remove, run the remove command: qlik user rm <userId>

Let me know how it goes!

Live and Breathe Qlik & AWS.
Follow me on my LinkedIn | Know IPC Global at ipc-global.com

Thomas23
Contributor III
Contributor III
Author

Hello Hugo,
the CLI statement works, I can delete a user.

Is it possible to use a list of IDs as argument?

Regards
Thomas

hugo_andrade
Partner - Specialist
Partner - Specialist

Nice @Thomas23 !

I'm happy it helped.

You can only delete one user at a time with the command, but you can stack them to run in sequence.

You can use Excel to format the sequence of calls. Copy all of them and paste at once on Command Line.

Each line will execute the user removal, and automatically proceed to the next one.

See example:

hugo_andrade_0-1756754155360.png

Then you copy the resulting column into Command Line and let it do its magic.

Please like and mark as solved if this helps you.

Thanks!

Live and Breathe Qlik & AWS.
Follow me on my LinkedIn | Know IPC Global at ipc-global.com

Thomas23
Contributor III
Contributor III
Author

Hi Hugo,

it works fine.

Thank you

Thomas