Announcement

Migration of this forum

Dear users of this forum,

we are pleased to inform you that we will be updating the software behind this forum in the near future.

Existing posts, users and categories will remain untouched.

Important:

  • Each user will need to reset their password.
  • Please select "I forgot my password".
  • Enter the email address you used to register in this forum.
  • You will receive an email with a link to set a new password.
  • Please choose a new (secure) password and confirm the process.

We will keep you informed in the pinned thread.

Kind regards,
Your ReportServer Team


Migration des Forums

Liebe Nutzer dieses Forums,

wir freuen uns, euch mitteilen zu können, dass wir in naher Zukunft die Software hinter diesem Forum aktualisieren werden.

Existierende Beiträge, Nutzer und Kategorien bleiben weiterhin bestehen!

Wichtig:

  • Jeder Nutzer muss sein Passwort neu vergeben.
  • Wählt dazu einfach "Ich habe mein Passwort vergessen".
  • Gebt die E-Mail-Adresse ein, mit der ihr registriert seid.
  • Ihr erhaltet eine E-Mail mit einem Link zur Passwortvergabe.
  • Bitte wählt ein neues (sicheres) Passwort und bestätigt den Vorgang.

Wir halten euch im angepinnten Beitrag auf dem Laufenden!

Mit vielen Grüßen
Euer ReportServer Team

#1 2024-05-16 08:20:01

sakunthala
Member
Registered: 2024-04-17

reports scheduling using Groovy script and execute using url

Hi,
I have written a groovy script to create schedule for a given report.
Report Id and the scheduled date are the parameters of this script.
When I executed this script from the CLI command it works fine and schedule is created as expected
exec -c scheduller.groovy 23086 'at 17.05.2024 17:30'

But I want to execute this groovy script via url and I was trying below url for this

http://192.91.199.194:81/reportserver/#fileservermgr/scriptAccess?id=71312&args=23086%20'at%2017.05.2024%2017:30'&commit=true

But it does not execute my script (there is norecords in my scheduled list)
can I know if anything wrong in this url?
Thank you

Last edited by sakunthala (2024-05-20 09:17:04)

Offline

#2 2024-05-17 07:06:27

IF_Felix
Moderator
Registered: 2022-08-01

Re: reports scheduling using Groovy script and execute using url

Hi sakunthala!

Wow! Cool idea!

Maybe those apostrophes ' are your problem? Try using %27 instead (this should be equivalent to ')

I'm always using JS (JQuery) functions to build my request. Especially "encodeURIComponent"

$.ajax({
               type: "POST",
               url: url,
               data: { args: encodeURIComponent(JSON.stringify({ user: $("#rs_username").val(), pw: $("#rs_password").val()})) },
               success: function (resp) { $("#rs_logout").show() },
               error: function (resp) { },
              
          })

If you just need your hard encoded URL... change type to "GET" and have a look into the "development console" of your browser wink in "network" you can see the used url... since i'm lazy => this is how i get my urls to paste them where i use them "hard coded"


Softwareentwickler bei Infofabrik

Offline

#3 2024-05-20 09:27:02

sakunthala
Member
Registered: 2024-04-17

Re: reports scheduling using Groovy script and execute using url

hi Felix,
Thank you for your answer. But still I am having the same problem in this url. When I copy and paste the url in the browser the script (id=71312) does not execute. It loads the reportserver dashboard instead
http://<ip:port>/reportserver/#fileservermgr/scriptAccess?id=71312

I referred to this documentation https://reportserver.net/en/guides/scri … ts-via-URL

Thank you
Sakunthala

Last edited by sakunthala (2024-05-20 10:24:45)

Offline

#4 2024-05-21 06:13:41

IF_Felix
Moderator
Registered: 2022-08-01

Re: reports scheduling using Groovy script and execute using url

Hi,
"#fileservermgr" is wrong at this point! try http://<ip:port>/<tomcat webapps dir>/reportserver/scriptAccess?id=71312

where tomcat webapps dir is the directory where your ReportServer is installed => if i'm lazy I install it under root, the moste people (as well as our documentation) prefere "webapps/reportserver/"


Softwareentwickler bei Infofabrik

Offline

#5 2024-05-21 09:12:41

sakunthala
Member
Registered: 2024-04-17

Re: reports scheduling using Groovy script and execute using url

hi Felix,
Yes now it seems script is executing. Thank you for your answer.
Sakunthala

Offline

#6 2024-05-21 10:59:11

sakunthala
Member
Registered: 2024-04-17

Re: reports scheduling using Groovy script and execute using url

hi Felix,

Now I can execute the script using the url. But still It doesn't create a schedule for me. When I check the log I can see the below error. This error occurs when I execute the script using commands as well. Do you have any solution for this? This is my groovy script

import net.datenwerke.security.service.usermanager.UserManagerService
import net.datenwerke.rs.core.service.reportmanager.ReportService
import net.datenwerke.rs.scheduler.service.scheduler.jobs.report.ReportExecuteJob
import net.datenwerke.rs.core.service.reportmanager.ReportExecutorService
import net.datenwerke.rs.core.service.datasinkmanager.DatasinkTreeService
import net.datenwerke.rs.ftp.service.ftp.definitions.SftpDatasink
import net.datenwerke.rs.ftp.service.ftp.action.ScheduleAsSftpFileAction
import net.datenwerke.scheduler.service.scheduler.nlp.NlpTriggerService
import net.datenwerke.scheduler.service.scheduler.SchedulerService



  REPORT_ID = 23086
  DATE_EXPRESSION = 'at 25.05.2024 17:30'
  JOB_NAME = 'Test Job'
  JOB_DESCRIPTION = 'A Test Job Description'
  OUTPUT_FORMAT = ReportExecutorService.OUTPUT_FORMAT_PDF
  OWNER_ID = 6L                       // the ID of the Owner
  EXECUTOR_ID = 6L                    // the ID of the Executor
  RECIPIENT_IDS = [6L]            // the IDs of the Recipients

  // SFTP settings
  SFTP_DATASINK = 'Demo SFTP Datasink'
  FOLDER = 'Archive'
  SFTP_FILENAME='My Report'


    def triggerService = GLOBALS.getInstance(NlpTriggerService)
    def schedulerService = GLOBALS.getInstance(SchedulerService)
    def reportService = GLOBALS.getInstance(ReportService)
    def userManagerService = GLOBALS.getRsService(UserManagerService)
    def datasinkTreeService = GLOBALS.getInstance(DatasinkTreeService)

  //def reportId = args[0].toInteger()
    def report = reportService.getReportById(REPORT_ID)  // get Report by ID

    def owner = userManagerService.getNodeById(OWNER_ID)
    def executor = userManagerService.getNodeById(EXECUTOR_ID)
    def recipients = userManagerService.getUsers(RECIPIENT_IDS)
   

    /* create the Report Job and add the corresponding owner, executor and recipients */
    def job = new ReportExecuteJob(report: report, owners: [owner] ,executor: executor, recipients: recipients as List, outputFormat: OUTPUT_FORMAT)

    def sftpDatasink = datasinkTreeService.getDatasinkByName(SFTP_DATASINK)


    def action = new ScheduleAsSftpFileAction( name: SFTP_FILENAME,folder: FOLDER)


    /* add the description, version, actions etc. */
    job.title = JOB_NAME
    job.description = JOB_DESCRIPTION
    job.actions = [action]

    /* parse the date with nlp */
    def trigger = triggerService.parseExpression DATE_EXPRESSION

    /* schedule the job via the schedulerService */
    schedulerService.schedule job, trigger
 
-------------------------Error Log ------------------------------------------------------------------


21-May-2024 16:19:08.267 WARNING [scriptExec-30] net.datenwerke.rs.incubator.service.schedulernotification.SchedulerNotificationHooker.jobScheduled scheduler notification error
    java.lang.NullPointerException: Cannot invoke "net.datenwerke.security.service.usermanager.UserManagerService.getUsers(java.util.Collection, boolean)" because "this.userService" is null
        at net.datenwerke.rs.scheduler.service.scheduler.jobs.report.ReportExecuteJob.getRecipients(ReportExecuteJob.java:103)
        at net.datenwerke.rs.incubator.service.schedulernotification.SchedulerNotificationHooker.jobScheduled(SchedulerNotificationHooker.java:191)
        at net.datenwerke.scheduler.service.scheduler.SchedulerServiceImpl.lambda$1(SchedulerServiceImpl.java:260)
        at java.base/java.util.ArrayList.forEach(ArrayList.java:1511)
        at net.datenwerke.scheduler.service.scheduler.SchedulerServiceImpl.schedule(SchedulerServiceImpl.java:260)
        at org.codehaus.groovy.vmplugin.v8.IndyInterface.fromCache(IndyInterface.java:321)
        at myscripts.Script48.run(Script48.groovy:53)
        at org.codehaus.groovy.jsr223.GroovyScriptEngineImpl.eval(GroovyScriptEngineImpl.java:331)
        at org.codehaus.groovy.jsr223.GroovyCompiledScript.eval(GroovyCompiledScript.java:72)
        at net.datenwerke.rs.scripting.service.scripting.engines.GroovyEngine.eval(GroovyEngine.java:78)
        at net.datenwerke.rs.scripting.service.scripting.ScriptingServiceImpl.executeScript(ScriptingServiceImpl.java:231)
        at net.datenwerke.rs.scripting.service.scripting.ScriptingServiceImpl.executeScript(ScriptingServiceImpl.java:282)
        at net.datenwerke.rs.scripting.service.scripting.ScriptingServiceImpl$$EnhancerByGuice$$1145253108.GUICE$TRAMPOLINE(<generated>)
        at com.google.inject.internal.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:74)
        at net.datenwerke.rsenterprise.license.service.EnterpriseCheckInterceptor.invoke(EnterpriseCheckInterceptor.java:40)
        at com.google.inject.internal.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:75)
        at com.google.inject.internal.InterceptorStackCallback.invoke(InterceptorStackCallback.java:55)
        at net.datenwerke.rs.scripting.service.scripting.ScriptingServiceImpl$$EnhancerByGuice$$1145253108.executeScript(<generated>)
        at net.datenwerke.rs.scripting.service.scripting.ScriptingServiceImpl.executeScript(ScriptingServiceImpl.java:335)
        at net.datenwerke.rs.scripting.service.scripting.ScriptingServiceImpl$$EnhancerByGuice$$1145253108.GUICE$TRAMPOLINE(<generated>)
        at com.google.inject.internal.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:74)
        at net.datenwerke.rsenterprise.license.service.EnterpriseCheckInterceptor.invoke(EnterpriseCheckInterceptor.java:40)
        at com.google.inject.internal.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:75)
        at com.google.inject.internal.InterceptorStackCallback.invoke(InterceptorStackCallback.java:55)
        at net.datenwerke.rs.scripting.service.scripting.ScriptingServiceImpl$$EnhancerByGuice$$1145253108.executeScript(<generated>)
        at net.datenwerke.rs.scripting.service.scripting.ScriptingServiceImpl.executeScript(ScriptingServiceImpl.java:307)
        at net.datenwerke.rs.scripting.service.scripting.ScriptingServiceImpl$$EnhancerByGuice$$1145253108.GUICE$TRAMPOLINE(<generated>)
        at com.google.inject.internal.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:74)
        at net.datenwerke.rsenterprise.license.service.EnterpriseCheckInterceptor.invoke(EnterpriseCheckInterceptor.java:40)
        at com.google.inject.internal.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:75)
        at com.google.inject.internal.InterceptorStackCallback.invoke(InterceptorStackCallback.java:55)
        at net.datenwerke.rs.scripting.service.scripting.ScriptingServiceImpl$$EnhancerByGuice$$1145253108.executeScript(<generated>)
        at net.datenwerke.rs.scripting.service.scripting.terminal.commands.ExecScriptCommand.doTransactionExecute(ExecScriptCommand.java:363)
        at net.datenwerke.rs.scripting.service.scripting.terminal.commands.ExecScriptCommand$$EnhancerByGuice$$881504958.GUICE$TRAMPOLINE(<generated>)
        at com.google.inject.internal.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:74)
        at com.google.inject.persist.jpa.JpaLocalTxnInterceptor.invoke(JpaLocalTxnInterceptor.java:64)
        at com.google.inject.internal.InterceptorStackCallback$InterceptedMethodInvocation.proceed(InterceptorStackCallback.java:75)
        at com.google.inject.internal.InterceptorStackCallback.invoke(InterceptorStackCallback.java:55)
        at net.datenwerke.rs.scripting.service.scripting.terminal.commands.ExecScriptCommand$$EnhancerByGuice$$881504958.doTransactionExecute(<generated>)
        at net.datenwerke.rs.scripting.service.scripting.terminal.commands.ExecScriptCommand$1$1.doFilter(ExecScriptCommand.java:289)
        at com.google.inject.servlet.FilterChainInvocation.doFilter(FilterChainInvocation.java:89)
        at com.google.inject.servlet.ManagedFilterPipeline.dispatch(ManagedFilterPipeline.java:121)
        at com.google.inject.servlet.GuiceFilter.doFilter(GuiceFilter.java:133)
        at net.datenwerke.rs.scripting.service.scripting.terminal.commands.ExecScriptCommand$1.call(ExecScriptCommand.java:284)
        at net.datenwerke.rs.scripting.service.scripting.terminal.commands.ExecScriptCommand$1.call(ExecScriptCommand.java:1)
        at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
        at java.base/java.lang.Thread.run(Thread.java:833)

Offline

#7 2024-05-22 04:02:16

sakunthala
Member
Registered: 2024-04-17

Re: reports scheduling using Groovy script and execute using url

hi Felix,
I resolved that issue after added scheduler permission to my user. Thank you for your support.

Sakunthala

Offline

Board footer

Powered by FluxBB