Seal Report Forum
»
Report Edition
»
Reports
»
Use Restriction Value as Parameter in Email Subject Output
Rank: Member
Groups: Registered
Joined: 9/4/2015(UTC) Posts: 23 Location: ottawa Thanks: 7 times Was thanked: 2 time(s) in 2 post(s)
|
I am starting to get into the email functionality of Seal. I see that for the email output you can define a Subject. Is there a way to take one of your Restriction parameters from the view and use is in the email Subject at run time instead of having a static email Subject?
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 12/20/2013(UTC) Posts: 1,209 Thanks: 14 times Was thanked: 206 time(s) in 199 post(s)
|
Yes it is possible. You have to customize the 'Pre-generation script' property of your output and assign the restriction value to the output EmailSubject: Code:ReportOutput output = Model;
var restriction = output.Report.Models[0].Restrictions.FirstOrDefault(i => i.DisplayNameEl == "Product Name");
if (restriction != null)
{
output.EmailSubject = restriction.Value1;
}
actually you modify your output as you wish, just have to know the ReportOutput object model. EmailSubject EmailBody EmailHtmlBody EmailTo EmailCC EmailMessagesInBody EmailZipAttachments EmailZipPassword EmailSkipAttachments EmailFrom EmailReplyTo
|
|
|
|
Rank: Member
Groups: Registered
Joined: 9/4/2015(UTC) Posts: 23 Location: ottawa Thanks: 7 times Was thanked: 2 time(s) in 2 post(s)
|
OK so I'm starting to use this and cant seem to get it working. I have a report with 7 models, each model has a restriction called "Build" that is prompted at run time. I have set my Pre-generation script to be Code:@using Seal.Model
@{
ReportOutput output = Model;
var restriction = output.Report.Models[0].Restrictions.FirstOrDefault(i => i.DisplayNameEl == "Build");
if (restriction != null)
{
output.EmailSubject = "Test Email Subject With Restriction: " + restriction.Value1;
}
string result = "1"; //Set result to 0 to cancel the report.
}
@Raw(result)
The email subject never seems to have the restriction value in it, only the string "Test Email Subject With Restriction: " Am I doing something wrong here. Note that I'm using Seal 1.8. In the process of upgrading to 2.1. Thx.
|
|
|
|
Rank: Administration
Groups: Administrators
Joined: 12/20/2013(UTC) Posts: 1,209 Thanks: 14 times Was thanked: 206 time(s) in 199 post(s)
|
I made a quick test with 3 models and a restriction of type string and it works fine. I am using the 2.1.1 Note that if the restriction is an enumerated list, the values selected are in the list: List<string> EnumValues so it would be restriction.EnumValues[0] for the first value selected, plus a helper call to have the enum text. This gives: Code:@using Seal.Model
@{
ReportOutput output = Model;
var restriction = output.Report.Models[0].Restrictions.FirstOrDefault(i => i.DisplayNameEl == "Category");
if (restriction != null)
{
output.EmailSubject = "Test Email Subject With Restriction: " + restriction.GetEnumDisplayValue(restriction.EnumValues[0]);
}
string result = "1"; //Set result to 0 to cancel the report.
}
@Raw(result)
Edited by user Friday, June 3, 2016 3:34:13 PM(UTC)
| Reason: Not specified
|
1 user thanked epf for this useful post.
|
|
|
Rank: Member
Groups: Registered
Joined: 9/4/2015(UTC) Posts: 23 Location: ottawa Thanks: 7 times Was thanked: 2 time(s) in 2 post(s)
|
I was using an Enum so restriction.GetEnumDisplayValue(restriction.EnumValues[0]) works for me.
Much appreciated. Thx.
|
|
|
|
Seal Report Forum
»
Report Edition
»
Reports
»
Use Restriction Value as Parameter in Email Subject Output
Forum Jump
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.