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
plinq  
#1 Posted : Thursday, February 21, 2019 12:00:54 PM(UTC)
plinq

Rank: Newbie

Groups: Registered
Joined: 2/21/2019(UTC)
Posts: 3
China

Thanks: 1 times
I created two models that both had restrictions and rendered them in two tabpages in a single report.
The two models were highly related to each other.Effectively,they represented the same data in different dimensions.(like one was plain data,the other one was pivoted)

The problem is that only the restriction of the first model is prompted when the reprot is executed.
Furthermore,since the base data was effectively the same,it would be great if users could set restrictions only once.
epf  
#2 Posted : Thursday, February 21, 2019 1:45:33 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)
You may have 2 approach to handle this:
You can create a view or table that have a common join with the 2 tables and you will set the restriction only the date if this table.
By SQL joins the restrictions will be applied on your 2 models.

Or you can use the Pre-Load script of one of the 2 model to set the restriction values.
The script below shows how to copy the 2 dates values from one model to the other.

Code:
@using Seal.Model
@using System.Data
@{
    ReportModel model = Model;
	ReportExecutionLog log = model.Report;
    List<ReportElement> elements = model.Elements;
    List<ReportRestriction> restrictions = model.Restrictions;

    log.LogMessage("Processing the model 'Pre Load Script'");
    var modelMaster = model.Report.Models.FirstOrDefault(i => i.Name.StartsWith("positions"));
    
    restrictions[0].Date1 = modelMaster.Restrictions[0].Date1;
    restrictions[0].Date2 = modelMaster.Restrictions[0].Date2;
}
thanks 1 user thanked epf for this useful post.
plinq on 2/22/2019(UTC)
plinq  
#3 Posted : Friday, February 22, 2019 9:06:11 AM(UTC)
plinq

Rank: Newbie

Groups: Registered
Joined: 2/21/2019(UTC)
Posts: 3
China

Thanks: 1 times
Originally Posted by: epf Go to Quoted Post
You may have 2 approach to handle this:
You can create a view or table that have a common join with the 2 tables and you will set the restriction only the date if this table.
By SQL joins the restrictions will be applied on your 2 models.

Or you can use the Pre-Load script of one of the 2 model to set the restriction values.
The script below shows how to copy the 2 dates values from one model to the other.

Code:
@using Seal.Model
@using System.Data
@{
    ReportModel model = Model;
	ReportExecutionLog log = model.Report;
    List<ReportElement> elements = model.Elements;
    List<ReportRestriction> restrictions = model.Restrictions;

    log.LogMessage("Processing the model 'Pre Load Script'");
    var modelMaster = model.Report.Models.FirstOrDefault(i => i.Name.StartsWith("positions"));
    
    restrictions[0].Date1 = modelMaster.Restrictions[0].Date1;
    restrictions[0].Date2 = modelMaster.Restrictions[0].Date2;
}

Thank you.I've tested the sencod approach.
So it's intended behavior that only the restrictions of the master model are prompted rather than me not setting things properly?
plinq  
#4 Posted : Friday, February 22, 2019 12:40:55 PM(UTC)
plinq

Rank: Newbie

Groups: Registered
Joined: 2/21/2019(UTC)
Posts: 3
China

Thanks: 1 times
Well,I tried again.There was something strange.
The restrictions on the second models won't show up has been bothering me for a long time and it did be that way when I created a report yesterday ,which led to this post.But when I added another restriction on the two models,restrictions on the second model were promoted.
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.