logo

Warning: The forum is now for consultation only. Please use GitHub Discussions to post any questions or comments.


Welcome Guest ! To enable all features please Login or Register.

Notification

Icon
Error

Options
Go to last post Go to first unread
sealfan  
#1 Posted : Wednesday, November 4, 2015 8:21:29 PM(UTC)
sealfan

Rank: Member

Groups: Registered
Joined: 9/4/2015(UTC)
Posts: 23
Canada
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?
epf  
#2 Posted : Thursday, November 5, 2015 11:00:15 AM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 1,209
Switzerland

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
sealfan  
#3 Posted : Friday, June 3, 2016 2:27:07 PM(UTC)
sealfan

Rank: Member

Groups: Registered
Joined: 9/4/2015(UTC)
Posts: 23
Canada
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.
epf  
#4 Posted : Friday, June 3, 2016 3:32:27 PM(UTC)
epf

Rank: Administration

Groups: Administrators
Joined: 12/20/2013(UTC)
Posts: 1,209
Switzerland

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

thanks 1 user thanked epf for this useful post.
sealfan on 6/3/2016(UTC)
sealfan  
#5 Posted : Friday, June 3, 2016 5:27:26 PM(UTC)
sealfan

Rank: Member

Groups: Registered
Joined: 9/4/2015(UTC)
Posts: 23
Canada
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.
Users browsing this topic
Guest
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.