Passing parameters from process to report

Hi Community

I have a custom report. Four parameters are defined to run the query but two of them are customizable by the user while the other two are variable and their value can be assigned only by the process (from example RPS_RPSSubscription_Send_Report) that create and send the report. In particular, the parameter DateFrom and DateTo must be set not by the user but accordingly to the scheduled period. For example, if a report is scheduled quarterly, then the DateFrom should be datetime.now -3 months and the DateTo should be datetime.now. It is quite easy to calculate (in the pre-script for generating section) the correct dates in the process, but I can’t find a way to bind the calculated dates to the report’s parameters DateFrom – DateTo in the report.

Please suggest a solution if someone know how to do that.

 

Thanks in advance

Alberto

Parents Reply Children
  • I Markus

    Thanks a lot for your quick answer.

    The version is 8.12

     Thanks again

    Alberto

  • Binding calculated dates from the process to these two parameters should be doable in two ways.

    Option 1: User the process step parameters ParamName1(..2) and ParamValue1(..2) to do so. Set the ParamName.. parameters to DateFrom and DateEnd and set the ParameterValue... parameters accordingly. That should do the trick.

    Option 2: Did you think about using the built-in parameters ranges as DateFrom and DateTo? You will find more in this thread https://www.oneidentity.com/community/identity-manager/f/forum/27894/syntax-for-date-range-parameter-in-report-editor

  • Hi Markus, I really appreciate your help.

    I am interested in the first option. I did what you suggested but it seems it does not work as expected.

    In the Designer, I set the following

    1. In the “Parameters” tab of the step “Generate Report” I set:
      1. ParamName1 := value = “FromDate”
      2. ParamName2 := value = “ToDate”
      3. ParamValue1 := Value = values("FromDate") – I calculated FromDate in the pre-generating session
      4. ParamValue2 := Value = values("ToDate") – I calculated ToDate in the pre-generating section

    In the Report Editor, i set the followings:

    1. In the report, I have, among the others “Defined Parameters”:
      1. FromDate; parameter type: “User Prompt”
      2. ToDate; parameter type: “User Prompt”

    For both the parameters, in the tab “General”:

    1. Parameter Type: user prompt
    2. Description: <empty>
    3. Sort Order: <empty>
    4. Mandatory Parameter: no
    5. Show in parameter subset: yes
    6. Can be overwritten: yes

    For both the parameters, in the tab “Value definition”:

    • Date Type: Date
    • Date add-on: Date Only
    • Range: inherited
    • Multivalue: inherited
    • Data Source: none
    • Display Pattern: <empty>
    • Emply value overrides: checked
    • Sample Value: 1/1/2020 12:00:00 AM
    • Default Value: <empty>

    For both the parameters, in the tab “Value Calculation”:

    • Valuation script: <empty>
    • Validation script: <empty>

    I have tried many combinations for Valulation script, such as value = $PC(FromDate)$, value = values(“FromDate”) but of course, I only got compiling errors or similar.

    Please, what am I missing?

    Thanks again

    Alberto

  • Hi Alberto,

    I looked into the source code of the report component and must correct myself. If you specify a parameter set (which is specified for the subscriptions) you cannot overload the parameters using the parametername & parametervalue parameters.

    So let's try either the value calculation or the range parameters. Can you share the code you are using to calculate the DateFrom and DateTo parameters in your pre-script?

  • Hi Markus,

    As you requested, just a small excerpt of the pre-generating code.

    if $FK(UID_DialogSchedule).Name$.Contains("Monthly") then

          Dim DataInizio as DateTime=DateTime.now

          values("FromDate")=new DateTime(DataInizio.Year,DataInizio.Month,1)

          Dim mese as Integer=DateTime.Now.Month

          Dim LastDay as Integer= System.DateTime.DaysInMonth(DataInizio.Year,mese)

          values("ToDate")=new DateTime(DataInizio.Year,DataInizio.Month,lastday)

    What we would like to achieve, is:

    1. To have just one report (minimum maintenance)
    2. To automatically choose the range (I know about the range parameter and I have already used it) accordingly to the scheduling period (if the subscription has been scheduled every quarter, then the range should be 3 months and so on)
    3. Do not allow user to choose a different range than the one calculated from the scheduling interval. This last specification can be skipped but it would be nice to have it working.

    again, thanks a lot

    Alberto

  • Hi Alberto,

    I took the time to build a sample and hopefully the solution suits you.

    Pre-Requisites are:

    1. You need to calculate the FromDate and ToDate parameters in the valuation scripts of the parameter.
    2. You can calculate the FromDate based on the ToDate to avoid to call DateTime.Now more than one time.
    3. The order of the parameters should consider the dependencies you have in your code. So the order of FromDate should be lower than the one for ToDate
    4. You need to set the parameter type to FIX. In that case, the user will not get the option to specify it's own date.
    5. You need to compile the database after you have inserted or changed the code at your parameters.

    Here is, how it works for me:

    • FromDate

      ' Check if report is started via RPSSubscription
      If provider.Contains("UID_DialogSchedule") Then
      	If $FK(UID_DialogSchedule).Name$.Contains("Monthly") then
      		Dim DataInizio as DateTime=DateTime.now
      		' Set parameter FromDate
      		value = new DateTime(DataInizio.Year,DataInizio.Month,1)
      	End If
      End If
    • ToDate

      ' Check if report is started via RPSSubscription
      If provider.Contains("UID_DialogSchedule") Then
      	If $FK(UID_DialogSchedule).Name$.Contains("Monthly") then
      		' Fetch fromDate from other Parameter
      		Dim fromDate = DbVal.ConvertTo(Of Date)(ParameterSet("FromDate").Value)
      
      		Dim mese as Integer = fromDate.Month
      		Dim LastDay as Integer= System.DateTime.DaysInMonth(fromDate.Year, mese)
      		
      		' Set ToDate parameter
      		value = new DateTime(fromDate.Year,fromDate.Month, lastday)
      	End If
      End If
    HtH

  • Hi Markus,

    thanks a lot, it worked like a charm and as usual, you did a great job again! Thanks!

    But now, I have one more question about passing parameters to the report.

    Let me explain please.

    After I applied your code, I was able to handle to range (FromDate - ToDate) accordingly to the scheduled period. So I have tried to play a little bit with the two parameters, in particular, I set them as “User Prompt”. After that, I could see those parameters in the subscription page in the web portal, and as I expected, if I try to modify them, they are programmatically set back to the “right” calculated value related to the scheduled time. But I also realize this: if I change the value of the parameters, that triggers their recalculation, while, if a change the “Schedule”, nothing happens (at least I does not see any change in the parameters, even if when I request the report, the dates are correctly set according to the new scheduled period).

    Said this, my new question is: is there a way to trigger the parameters recalculation when the “Schedule” is changed from the web portal, in such a way user can see what would be the new dates?

    I hope I was clear… and, sincerely, thanks for your precious help.

    Alberto

  • Hi Alberto,

    sorry, but I am unable to answer that question. Maybe someone with more WebDesigner knowledge is able to answer this one.

    I know, that the values will be calculated at the time you are trying to access them, that's why the solution is using the correct values based on the schedule when you are rendering the report.

    If the WebDesigner parameter picker can be adopted to detect the change of the selected schedule and trigger a recalculation of the date properties is out of my knowledge.

    Markus

  • Hi Markus,

    Yes, you are right, probably I need to intercept the modification from the web designer. This is exactly what I was afraid I had to do. I hoped there was a “magic” option to trigger the recalculation from the report itself, but of course it was just a mere hope.

    Anyway, what you suggested earlier should be enough to implement the solution as wanted.

    Again, thanks

    Alberto