I will try to solve the problem of the token being visible left as an issue in the previous post 【Publisher】Try executing the scheduled task on Sharperlight instance B from Sharperlight instance A
Instead of triggering the scheduled task in client-side JavaScript, use the server-side method of triggering the scheduled task so that you don't have to use tokens on the client side.
To achieve that, I have another published report with a function defined to execute the scheduled task, and call it from the client-side JavaScript.
When the report is called, the functions defined in the report query are executed and triggering the task on the server side.
Preparing report for task launch
Create public reports that trigger tasks. When this report is called using the Sharperlight service, the query defined within it will be executed and the desired task will be triggered. Since this is the side that calls the task, it is created on the Sharperlight instance A side.
Launch Sharperlight Publisher.
Start creating a new published report with the New
button.
Fill in the Code, Group and Title and start building your query with the Edit Query
button.
Since we only need to execute a task, the query result only needs to be one row, so let's set the Product
to System, the Table
to User Accounts, and the Mode
to the default value of CU.
Define task trigger using an expression for output item.
Define the Service Name, Token, and Task Name of Sharperlight instance B as constants in the Sharperlight system properties. Create trigger by referencing them.
Let's create it with 4 output items.
Service Name:
Get the service name of Sharperlight instance B defined in System Properties of Sharperlight instance A.
Task Name:
Defines the name of the task to be executed.
Token:
Get the token for Sharperlight instance B defined in System Properties of Sharperlight instance A.
Trigger:
Trigger of the task. Define the launch function by referencing the above items using control tags.
The trigger is now complete. you save. Running a query with the query preview feature actually kicks off the task. You can check the operation if you want.
Editting Validation Report
Now, let's edit the verification report created in the previous article (the token was completely exposed).
Instead of running the task launch function in JS, we just want to call the report created above to launch the task.
By doing so, the task launch function defined in the report's query for starting the task will work at the server side.
To do so, use the command DataSource
of the Sharperlight service.
A report called using the 'DataSource' command will not be displayed as a normal report, but will instead execute the contained query and return the resulting data set in JSON format to the client side.
This time, it's OK if the defined query is executed on the server side, so the task will be started, and the returned query result will be ignored.
Change this part of the previous JS code.
This is what it looks like here. You can see that the DataSource
command is used to call the report for launching the task.
Set this new code in the custom HTML option of the report for verification and save it.
Verification
Start the services of Sharperlight instances A and B.
View the validation report in your browser.
Open the definition of the Sharperlight scheduled task to be executed and keep the History tab visible.
Click the Execute Task
button in the verification report. Now go to the history tab of the task and view the history with the Refresh
icon.
Shows the history of tasks triggered by button clicks.
Try opening the debugger against the report for validation. You can't see the token this time.
Thank you.