<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Run Task for Specific User using Rest API in Qlik NPrinting</title>
    <link>https://community.qlik.com/t5/Qlik-NPrinting/Run-Task-for-Specific-User-using-Rest-API/m-p/1641491#M26744</link>
    <description>&lt;P&gt;btw&lt;/P&gt;&lt;P&gt;attaching image when this code starts. Keep in mind that using my code you would need set it up/configure to suite your environment. This because I often have to reuse the same endpoints in loops and within other procedures.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/22656iAFD840FF2FB8BE70/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 31 Oct 2019 01:05:36 GMT</pubDate>
    <dc:creator>Lech_Miszkiewicz</dc:creator>
    <dc:date>2019-10-31T01:05:36Z</dc:date>
    <item>
      <title>Run Task for Specific User using Rest API</title>
      <link>https://community.qlik.com/t5/Qlik-NPrinting/Run-Task-for-Specific-User-using-Rest-API/m-p/1641486#M26742</link>
      <description>&lt;P&gt;HI All,&lt;/P&gt;&lt;P&gt;I have succesfully setup the rest API to connect to Nprinting Setember 2019 and am able to load users,reload metadata and execute task all based on the steps provides by&amp;nbsp;&lt;A href="https://community.qlik.com/t5/user/viewprofilepage/user-id/49865" target="_self"&gt;&lt;SPAN class="login-bold"&gt;Gianluca_Perin&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp; in this post&amp;nbsp;&lt;A title="Nprinting API Call" href="https://community.qlik.com/t5/Qlik-NPrinting-Discussions/How-to-use-Qlik-NPrinting-APIs-inside-a-Qlik-Sense-load-script/m-p/54441#M1985" target="_blank" rel="noopener"&gt;Nprinting API Call&lt;/A&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I need some help though on modifying the task execution code to execute the task for a specific user when needed.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;So although&amp;nbsp;they may be 100s of users in the publish task I want the ability to run it just for one user. Any ideas on how this can be achieved?&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The current code is below.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Get Task&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;RestNPTasksMasterTable:
SQL SELECT
"__KEY_data",
(SELECT
"id",
"name",
"appId",
"__FK_items"
FROM "items" FK "__FK_items")
FROM JSON (wrap off) "data" PK "__KEY_data"
WITH CONNECTION( URL "https://NPSRVR:4993/api/v1/tasks", HTTPHEADER "cookie" "$(vCookie)" );
[task_items]:
LOAD [id] AS [tasks_taskId],
[name] AS [tasks_taskName],
[appId] AS [tasks_appId]
RESIDENT RestNPTasksMasterTable
WHERE NOT IsNull([__FK_items]) AND [appId] = '$(vAppId)';
let vTaskId = Peek('tasks_taskId',0,'task_items');
let vPublshTaskURL = 'https://NPSRVR:4993/api/v1/tasks/'&amp;amp;'$(vTaskId)'&amp;amp;'/executions';
DROP TABLE RestNPTasksMasterTable;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Execute Task&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;LIB CONNECT TO 'NPrinting REST Login (POST) (admin)';
RestNPTaskTriggerTable:
SQL SELECT
"__KEY_data"
FROM JSON (wrap off) "data" PK "__KEY_data"
WITH CONNECTION( URL "$(vPublshTaskURL)", HTTPHEADER "cookie" "$(vCookie)");
[_post_items]:
LOAD [__KEY_data] AS [__KEY_data]
RESIDENT RestNPTaskTriggerTable
WHERE NOT IsNull([__KEY_data]);
DROP TABLE RestNPTaskTriggerTable;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2019 00:46:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Qlik-NPrinting/Run-Task-for-Specific-User-using-Rest-API/m-p/1641486#M26742</guid>
      <dc:creator>didierodayo</dc:creator>
      <dc:date>2019-10-31T00:46:27Z</dc:date>
    </item>
    <item>
      <title>Re: Run Task for Specific User using Rest API</title>
      <link>https://community.qlik.com/t5/Qlik-NPrinting/Run-Task-for-Specific-User-using-Rest-API/m-p/1641487#M26743</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Running the task for 1 use via API call needs to take into consideration multiple factors:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;you are calling task with all settings beeing set under publish task properties, including:&lt;OL&gt;&lt;LI&gt;filters&lt;/LI&gt;&lt;LI&gt;destinations&lt;/LI&gt;&lt;LI&gt;users/groups&lt;/LI&gt;&lt;LI&gt;email etc..&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;From the list above you want to have users dynamic.&lt;/P&gt;&lt;P&gt;In order to achieve this I would&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;create NPrinitng user group&lt;/LI&gt;&lt;LI&gt;setup user group as recipient of this task&lt;/LI&gt;&lt;LI&gt;Using API associate only users I want to send report to with this group&lt;OL&gt;&lt;LI&gt;this can be found in my library:&amp;nbsp;&lt;A href="https://nprintingadventures.wordpress.com/2019/04/08/nprinting-api-qlik-rest-subroutines/" target="_blank" rel="noopener"&gt;https://nprintingadventures.wordpress.com/2019/04/08/nprinting-api-qlik-rest-subroutines/&lt;/A&gt;&lt;OL&gt;&lt;LI&gt;setting users-group allocation is configured in lines 448-544 and further. In my code I use XLS file to define this. But the source of users and groups can be anything as long as you can read it in qlik.&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;That being said - there is no API endpoint associating users with tasks. Instead there is an endpoint associating users with groups which you can modifiy before you trigger task and all the code is available in the link I have provided you. All what you need to do is then to feed your data in it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;regards&lt;/P&gt;&lt;P&gt;Lech&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2019 01:02:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Qlik-NPrinting/Run-Task-for-Specific-User-using-Rest-API/m-p/1641487#M26743</guid>
      <dc:creator>Lech_Miszkiewicz</dc:creator>
      <dc:date>2019-10-31T01:02:35Z</dc:date>
    </item>
    <item>
      <title>Re: Run Task for Specific User using Rest API</title>
      <link>https://community.qlik.com/t5/Qlik-NPrinting/Run-Task-for-Specific-User-using-Rest-API/m-p/1641491#M26744</link>
      <description>&lt;P&gt;btw&lt;/P&gt;&lt;P&gt;attaching image when this code starts. Keep in mind that using my code you would need set it up/configure to suite your environment. This because I often have to reuse the same endpoints in loops and within other procedures.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="1.png" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/22656iAFD840FF2FB8BE70/image-size/large?v=v2&amp;amp;px=999" role="button" title="1.png" alt="1.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2019 01:05:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Qlik-NPrinting/Run-Task-for-Specific-User-using-Rest-API/m-p/1641491#M26744</guid>
      <dc:creator>Lech_Miszkiewicz</dc:creator>
      <dc:date>2019-10-31T01:05:36Z</dc:date>
    </item>
    <item>
      <title>Re: Run Task for Specific User using Rest API</title>
      <link>https://community.qlik.com/t5/Qlik-NPrinting/Run-Task-for-Specific-User-using-Rest-API/m-p/1641492#M26745</link>
      <description>&lt;P&gt;Hi Lech,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I will go through your suggestion and revert. Thank you&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2019 01:15:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Qlik-NPrinting/Run-Task-for-Specific-User-using-Rest-API/m-p/1641492#M26745</guid>
      <dc:creator>didierodayo</dc:creator>
      <dc:date>2019-10-31T01:15:56Z</dc:date>
    </item>
    <item>
      <title>Re: Run Task for Specific User using Rest API</title>
      <link>https://community.qlik.com/t5/Qlik-NPrinting/Run-Task-for-Specific-User-using-Rest-API/m-p/1641493#M26746</link>
      <description>&lt;P&gt;No worries...&lt;/P&gt;&lt;P&gt;So in very short:&lt;/P&gt;&lt;P&gt;with your script and NPrinitng APi you will preaty much:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;authenticate&lt;/LI&gt;&lt;LI&gt;update user-group association so only user which yyou want ot send report to has the group associated&lt;/LI&gt;&lt;LI&gt;trigger task&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;cheers&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2019 01:20:32 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Qlik-NPrinting/Run-Task-for-Specific-User-using-Rest-API/m-p/1641493#M26746</guid>
      <dc:creator>Lech_Miszkiewicz</dc:creator>
      <dc:date>2019-10-31T01:20:32Z</dc:date>
    </item>
    <item>
      <title>Re: Run Task for Specific User using Rest API</title>
      <link>https://community.qlik.com/t5/Qlik-NPrinting/Run-Task-for-Specific-User-using-Rest-API/m-p/1641508#M26747</link>
      <description>&lt;P&gt;Hi Lech,&lt;/P&gt;&lt;P&gt;I am able to Authenticate, I can update the user's group Let's say to (TEST GROUP) but reviewing you routine I am still not sure how to amend you TASK Execute code to only run for that specific group. Are you able to advise what changes I need to apply to the&amp;nbsp;NP_GetExecutions&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2019 04:13:28 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Qlik-NPrinting/Run-Task-for-Specific-User-using-Rest-API/m-p/1641508#M26747</guid>
      <dc:creator>didierodayo</dc:creator>
      <dc:date>2019-10-31T04:13:28Z</dc:date>
    </item>
    <item>
      <title>Re: Run Task for Specific User using Rest API</title>
      <link>https://community.qlik.com/t5/Qlik-NPrinting/Run-Task-for-Specific-User-using-Rest-API/m-p/1641510#M26748</link>
      <description>&lt;P&gt;You setup publish task to always send report to TASK GROUP and use Api to control who belongs to it&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2019 04:19:17 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Qlik-NPrinting/Run-Task-for-Specific-User-using-Rest-API/m-p/1641510#M26748</guid>
      <dc:creator>Lech_Miszkiewicz</dc:creator>
      <dc:date>2019-10-31T04:19:17Z</dc:date>
    </item>
    <item>
      <title>Re: Run Task for Specific User using Rest API</title>
      <link>https://community.qlik.com/t5/Qlik-NPrinting/Run-Task-for-Specific-User-using-Rest-API/m-p/1641515#M26749</link>
      <description>&lt;P&gt;Task execute code does have to not be amended as you always execute task and you always will send report to "TASK GROUP".&amp;nbsp;&lt;/P&gt;&lt;P&gt;You use API to change who belongs to the group therefore based on user-group association you will send report to the person who at that moment will belong to TASK GROUP.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Oct 2019 04:35:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/Qlik-NPrinting/Run-Task-for-Specific-User-using-Rest-API/m-p/1641515#M26749</guid>
      <dc:creator>Lech_Miszkiewicz</dc:creator>
      <dc:date>2019-10-31T04:35:41Z</dc:date>
    </item>
  </channel>
</rss>

