Issues with date parameters on a scheduled job in iHub (Part Deux)

Options
CodeRookie
edited February 11, 2022 in Analytics #1

Good morning, all!
Back in January, I posted a question about having problems with date parameters getting cached on a scheduled job, and received this code (which I put in the beforeFactory script), and it works perfectly:

var paramDate = "" + (params["HIDDEN_ReferenceDate"].value).getTime(); //Get reference parameter value as string
var currentDate = "" + (BirtDateTime.today()).getTime(); //Get current day as string
if(paramDate !== currentDate){ //If reference parameter and current day dont match then this is a scheduled report
iterator = reportContext.getDesignHandle().getParameters().iterator(); //Get report parameters
while (iterator.hasNext()) { //Loop through each report parameter
scalarParameterHandle = iterator.next(); //Get next report parameter handle
var paramName = scalarParameterHandle.getName(); //Get parameter name
var defaultValue = "" + scalarParameterHandle.getDefaultValueList()[0]; //Get parameter default value
if(defaultValue.indexOf("BirtDateTime")>-1) //If the parameter uses BirtDateTime for dynamic value
params[paramName].value = eval(defaultValue); //Update the parameter value with new dynamic value
}
}

Now, I'm trying to do the same thing with a datadesign (that is scheduled to run every 30 minutes), but am having issues with it. It seemed to run fine yesterday (before midnight), but subsequent runnings after midnight failed. The errors I'm getting are pointing to the above script. I thought I had copied out the exact error, but it didn't get captured.

My question: Is there a way to use the above script in generating the data object? Right now, I have it in the beforeOpen of one of the data sets, but I'm guessing it's not the correct place. Unfortunately, there aren't as many places in a datadesign to bury a script as there are in a report design.

Thanks in advance for any help!

Scott

Best Answer

  • Matthew L.
    Options

    Unfortunately this method doesn't work for .datadesigns
    For .datadesigns, I recommend using a computed column or you can use IDAPI to schedule your .datadesign (every 30 minutes) with updated parameter values

    Warning No formatter is installed for the format ipb

Answers

  • Matthew L.
    Options

    Unfortunately this method doesn't work for .datadesigns
    For .datadesigns, I recommend using a computed column or you can use IDAPI to schedule your .datadesign (every 30 minutes) with updated parameter values

    Warning No formatter is installed for the format ipb
  • Matthew,
    So, I found an easier way to go about it..... As this was calling a stored procedure, I just just did away with the date parameters and added this to the query:

    WHERE SL.scale_time_out >= DATEADD(mm, -12, GETDATE())
    AND SL.scale_time_out < DATEADD(dd, 1, GETDATE())

    This way, there's no question of what dates I'm getting every time it runs, as it's all contained withing the procedure.

    Thanks for the help!

    Scott