Link to home
Start Free TrialLog in
Avatar of Plucka
PluckaFlag for Australia

asked on

URGENT! Crystal Caching Paramaters.

Hi,

Using Coldfusion i'm calling a report that is run so frequently that i'm keeping the object open.

                  if (Not StructKeyExists(Application, Attributes.Persist)) {
                        Application[Attributes.Persist] = StructNew();
                        Application[Attributes.Persist].o_CrystalReport = CreateObject('component', '#Application.DbSource#.nuReport');
                        Application[Attributes.Persist].o_CrystalReport.Init(Application.DbServer);
                        Application[Attributes.Persist].o_CrystalReport.OpenReport(Attributes.Report,'rassdk://');
                        Application[Attributes.Persist].o_CrystalReport.SetDatasource(Application.DBSource,Application.DbServer,Application.DbUser,Application.DbPass);
                  }
                  Application[Attributes.Persist].o_CrystalReport.RunReport(5,'#GetPrinter.Path##Attributes.JobId#',Attributes.Parameters);

So the only bit that gets run more than once is the last line which just calls the report which will already be open. The problem that i'm having is the report is always run with the set of parameters that were first passed, even though im passing the parameters on this line, theres a couple of sub functions, but here's the bit of code that sets the parameters, can anyone tell me how to replace the existing parameters.

                  for (i=1; i lte ListLen(Arguments.parameters); i=i+1)
                  {
                        result = ListgetAt(Arguments.parameters,i);
                        ParamCollection = getClientDoc().DataDefinition().ParameterFields;
                        ParamToChange = ParamCollection.Item(i-1);
                        NewValue = GetFactory().CreateObject("CrystalReports.ParameterFieldDiscreteValue");
                        NewValue.Value = result;
                        TempParam = GetFactory().CreateObject("CrystalReports.ParameterField");
                        ParamToChange.CopyTo (TempParam);
                        TempParam.CurrentValues().Add(NewValue);
                        ParamController = getClientDoc().DataDefController().ParameterFieldController();
                        ParamController.Modify (ParamToChange, TempParam);
                  }
ASKER CERTIFIED SOLUTION
Avatar of Mike McCracken
Mike McCracken

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Plucka

ASKER

DiscardSavedData didn't work but closing the report each time did, I thought this would be an overhead, but most of the overhead (time) is in the connection to the ras objects, so just left this bit cached.

Avatar of lalitgupta_99
lalitgupta_99

Hi
Send a parameter with random value so tha teach time report will find that a new value to the paramter and report get refresh each time rather than opicking through cache
Avatar of Plucka

ASKER

thanks mlmcc, PS same question exists in Coldfusion Area if you want to paste same answer.
GLad I could help

mlmcc