You are not logged in.
Pages: 1
Hi,
On RS4.6.3-6104 I am trying your DataSink example script of the documentation :
https://reportserver.net/de/dokumentati … -datasinks
However I have an exception when I run the schedule:
Do have an idea what I have wrong here?
Thanks,
Regards,
Geoffrey
Offline
Hello,
You have a syntax error in your script.
to.collect{..} only works if "to" is a collection/iterable.
This is were your script differs from the example.
def to = 6L -> it should be def to = [6L]
Kind regards,
Adrian
Offline
Offline
Hello,
I see. The problem seems to be the following :
mailBuilder.create() expects the types (String, String, List) as arguements.
In this example the following types are given: (String, org.codehaus.groovy.runtime.GStringImpl, ArrayList)
The second arguement makes the call fail.
def subject = 'Script datasink'
def content = "ReportServer script datasink ${LocalDateTime.now()}"
In groovy 'asdf' indicates String and "asdf" indicates GString. You can type-convert using the "as" keyword
So either do the following
String content = "ReportServer script datasink ${LocalDateTime.now()}" as String
or pass it as String in your method call
def mail = mailBuilder.create(
subject,
content as String,
to.collect{userId -> userService.getNodeById(userId)})
.withAttachments(attachments)
.withZippedAttachments(attachmentFilename)
.build()
Both should remove this error.
Kind regards,
Adrian
Offline
Thanks for your feedback, however your suggestion seems to not resolve the problem completely:
error message: No signature of method: com.sun.proxy.$Proxy168.create() is applicable for argument types: (String, String, ArrayList) values: [Script datasink, ReportServer script datasink 2024-07-17T09:42:19.175826, [User{ID=39431, First name=Lemarechal, Last name=Gregory}, ...]]
Possible solutions: create(java.lang.String, java.lang.String, java.util.List, javax.mail.internet.InternetAddress), grep(), stream(), iterator() (groovy.lang.MissingMethodException)
Both of your suggestion seems not to give the same result.
Thanks,
Regards,
Geoffrey
Last edited by Geoffrey (2024-07-17 09:57:07)
Offline
Hello Geoffrey,
I took another look. I seems like there was a bugfix that changed the signatur 5 months ago which is not yet reflected in scripting examples:
- public MailBuilder create(@Assisted("subject") String subject, @Assisted("body") String body, List<User> recipients);
+ public MailBuilder create(@Assisted("subject") String subject, @Assisted("body") String body, List<User> recipients,
+ InternetAddress from);
This means that the create method now requires an additional parameter InternetAddress "from".
You could either manually create such an object for example like this:
import javax.mail.internet.InternetAddress
def user = userService.getNodeById(6)
String mailFrom = user.getEmail();
String mailFromName = user.getFirstname() + " " + user.getLastname();
def iaddress = new InternetAddress(mailFrom, mailFromName);
and pass it along:
def mail = mailBuilder.create(
subject,
content,
to.collect{userId -> userService.getNodeById(userId)},
iaddress)
.build()
or use the service method:
MailService
InternetAddress getMailFrom(User user, Optional<EmailDatasink> datasink); (here the passed datasink is a fallback if the given user has no email)
I hope this fixes your issue.
Kind regards,
Adrian
Offline
Hello Adrian,
Many thanks for you answer, now it works fine!
However it think that you should adapt the documentation accordantly.
I have a another the question: How in this script can I get the Ids of Recipient users configured I the schedule ? Instead to have it hardcoded in the script.
Thanks,
Regards,
Geoffrey
Offline
Hi,
Do you know how in the Datasink script I can get user Ids/E-mail addresses of the user configured as recipient on the schedule ?
Thanks,
Regards,
Geoffrey
Offline
Hi Geoffrey,
currently, the data available in script datasinks is shown here: https://reportserver.net/de/dokumentati … -datasinks
We raised a new ticket RS-8593 for adding the scheduler job infos to this list.
Regards,
Eduardo
Online
Hi Eduardo,
OK this means that is it currently not possible? I have already see this page of the documentation, but I was surprised that there a so little number variables available, this is why I am asking.
When do you think that it will be possible ?
The idea behind this, is instead to send the report as attachment to the users, to save the document on the file system and send by e-mail a HTTP link pointing to the saved report.
Thanks,
regards,
Geoffrey
Offline
Hi Geoffrey,
this ticket is currently on the development queue. We will write here when we have more information.
Regards,
Eduardo
Online
Pages: 1