Dashboard Report with Default value

Certified Senior Developer

Created an interface rule (see code attached) that displays information via a series of query rules (require a date or datetime value) and a default date value that can be changed by the user. The interface rule works great, but when I associate it with a Report, I get this error. 

Error Evaluating UI Expression Expression evaluation error at function rule!psh_disapprovedDashboard: Rule 'psh_disapproveddashboard' has 1 parameters, but instead passed 0 parameters.

I'm assuming it's because it's looking for the user input for 'ri!year_int'.  I specifically set a default value for this parameter in the interface rule so data would display regardless of whether or not the user changes the year.  Why won't this work when I associate the rule with a 'Report' object? Do I have to make it a

=load(
  ri!year_int: if(isnull(ri!year_int), year(now())-5, ri!year_int), 
  local!noByItobProducts: rule!psh_getNoByItobProducts(datetime(ri!year_int, month(now()), day(now()), 0, 0, 0)),
  local!noByItobProductsPagingInfo: a!pagingInfo(startIndex: 1, batchSize: 25, sort: a!sortInfo(field:"name", ascending: true)),  
  local!noRenewAgreements: rule!psh_getNoRenewalAgreements(date(ri!year_int, month(now()), day(now()))),
  local!noRenewalPagingInfo: a!pagingInfo(startIndex: 1, batchSize: 25, sort: a!sortInfo(field: "agreementDescription", ascending: true)),  
  
  with(
   local!noByItobProductDataSubset: todatasubset(local!noByItobProducts, local!noByItobProductsPagingInfo),
   local!noRenewalDataSubset: todatasubset(local!noRenewAgreements, local!noRenewalPagingInfo),


a!formLayout(
  label: "Disapproved Purchase Requests and Agreement Renewals",
  instructions: "Update Year Shown to Display Additional Items",
  contents: {
    a!sectionLayout(
    label: "",
    contents:{
      a!textField(
        label: "Disapproved Later Than:",
        labelPosition: "ADJACENT",
        value: ri!year_int,
        /*value: if(isnull(ri!year_int), year(now())-5, ri!year_int),*/
        saveInto: ri!year_int,
        refreshAfter: "KEYPRESS"
     )
   }
   ),
    a!sectionLayout(
      label: "New Purchases Disapproved By ITOB",
      contents: {
        a!gridField(
          labelPosition: "ABOVE",
          totalCount: local!noByItobProductDataSubset.totalCount,
          columns: {
            a!gridTextColumn(
              label: "Product", 
              field: "name",
              data: index(local!noByItobProductDataSubset.data, "name", null)),
            a!gridTextColumn(
              label: "Decided By",
              data: index(local!noByItobProductDataSubset.data, "decidedBy", null)),
            a!gridTextColumn(
              label: "ITOB Decision Date", 
              data: index(local!noByItobProductDataSubset.data, "itobDateTime", null)),
            a!gridTextColumn(
              label: "Disapproval Reason", 
              data: index(local!noByItobProductDataSubset.data, "itobFeedback", null))
          },
          value: local!noByItobProductsPagingInfo,
          saveInto: {
            a!save(
              local!noByItobProductsPagingInfo,
              if(
              isnull(
                save!value.sort
              ),
              local!noByItobProductsPagingInfo,
              if(
                length(
                save!value.sort.field
                ) <= 0,
                local!noByItobProductsPagingInfo,
               a!pagingInfo(
                startIndex: save!value.startIndex,
                batchSize: save!value.batchSize,
                sort: a!sortInfo(
                field: save!value.sort.field,
                ascending: save!value.sort.ascending
                )
               )
              )
             )
            )
  		  }
        )
      }
    ),
    
    a!sectionLayout(
      label: "Agreements Not Renewed",
      contents: {
        a!gridField(
          labelPosition: "ABOVE",
          totalCount: local!noRenewalDataSubset.totalCount,
          columns: {
            a!gridTextColumn(
              label: "Product",
              field:"agreementDescription",
              data: index(local!noRenewalDataSubset.data, "agreementDescription", null)
            ),
            a!gridTextColumn(
              label: "Submitted By",
              data: index(local!noRenewalDataSubset.data, "submittedBy", null)
            ),
            a!gridTextColumn(
              label: "Current Expiration Date",
              data: index(local!noRenewalDataSubset.data, "expiredDate", null)
            )
          },
          value: local!noRenewalPagingInfo,
              saveInto: {
        				a!save(
        				  local!noRenewalPagingInfo,
        				  if(
        					isnull(
        					  save!value.sort
        					),
        					local!noRenewalPagingInfo,
        					if(
        					  length(
        						save!value.sort.field
        					  ) <= 0,
        					  local!noRenewalPagingInfo,
        					  a!pagingInfo(
        						startIndex: save!value.startIndex,
        						batchSize: save!value.batchSize,
        						sort: a!sortInfo(
        						  field: save!value.sort.field,
        						  ascending: save!value.sort.ascending
        						)
        					 )
        					)
        				 )
        				)
      		 }
        )
      }
    )
    

  }

)
)
)
n Action and create a process model to display it? See attached for SAIL code.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Reports do not pass in rule inputs, which is why your interface is breaking: "Rule ... has 1 parameters, but instead [the report context] passed 0 parameters". You can refactor your interface by removing the rule input, adding a new local variable at the top of your load, and setting this new load variable with a default value. Ex.

    =load(
      local!year_int: year(now())-5, 
      local!noByItobProducts: rule!psh_getNoByItobProducts(datetime(local!year_int, month(now()), day(now()), 0, 0, 0)),
      local!noByItobProductsPagingInfo: a!pagingInfo(startIndex: 1, batchSize: 25, sort: a!sortInfo(field:"name", ascending: true)),  
      local!noRenewAgreements: rule!psh_getNoRenewalAgreements(date(local!year_int, month(now()), day(now()))),
      local!noRenewalPagingInfo: a!pagingInfo(startIndex: 1, batchSize: 25, sort: a!sortInfo(field: "agreementDescription", ascending: true)),  
      
      with(
       local!noByItobProductDataSubset: todatasubset(local!noByItobProducts, local!noByItobProductsPagingInfo),
       local!noRenewalDataSubset: todatasubset(local!noRenewAgreements, local!noRenewalPagingInfo),
    
    
    a!formLayout(
      label: "Disapproved Purchase Requests and Agreement Renewals",
      instructions: "Update Year Shown to Display Additional Items",
      contents: {
        a!sectionLayout(
        label: "",
        contents:{
          a!textField(
            label: "Disapproved Later Than:",
            labelPosition: "ADJACENT",
            value: local!year_int,
            /*value: if(isnull(local!year_int), year(now())-5, local!year_int),*/
            saveInto: local!year_int,
            refreshAfter: "KEYPRESS"
         )
       }
       ),
        a!sectionLayout(
          label: "New Purchases Disapproved By ITOB",
          contents: {
            a!gridField(
              labelPosition: "ABOVE",
              totalCount: local!noByItobProductDataSubset.totalCount,
              columns: {
                a!gridTextColumn(
                  label: "Product", 
                  field: "name",
                  data: index(local!noByItobProductDataSubset.data, "name", null)),
                a!gridTextColumn(
                  label: "Decided By",
                  data: index(local!noByItobProductDataSubset.data, "decidedBy", null)),
                a!gridTextColumn(
                  label: "ITOB Decision Date", 
                  data: index(local!noByItobProductDataSubset.data, "itobDateTime", null)),
                a!gridTextColumn(
                  label: "Disapproval Reason", 
                  data: index(local!noByItobProductDataSubset.data, "itobFeedback", null))
              },
              value: local!noByItobProductsPagingInfo,
              saveInto: {
                a!save(
                  local!noByItobProductsPagingInfo,
                  if(
                  isnull(
                    save!value.sort
                  ),
                  local!noByItobProductsPagingInfo,
                  if(
                    length(
                    save!value.sort.field
                    ) <= 0,
                    local!noByItobProductsPagingInfo,
                   a!pagingInfo(
                    startIndex: save!value.startIndex,
                    batchSize: save!value.batchSize,
                    sort: a!sortInfo(
                    field: save!value.sort.field,
                    ascending: save!value.sort.ascending
                    )
                   )
                  )
                 )
                )
      		  }
            )
          }
        ),
        
        a!sectionLayout(
          label: "Agreements Not Renewed",
          contents: {
            a!gridField(
              labelPosition: "ABOVE",
              totalCount: local!noRenewalDataSubset.totalCount,
              columns: {
                a!gridTextColumn(
                  label: "Product",
                  field:"agreementDescription",
                  data: index(local!noRenewalDataSubset.data, "agreementDescription", null)
                ),
                a!gridTextColumn(
                  label: "Submitted By",
                  data: index(local!noRenewalDataSubset.data, "submittedBy", null)
                ),
                a!gridTextColumn(
                  label: "Current Expiration Date",
                  data: index(local!noRenewalDataSubset.data, "expiredDate", null)
                )
              },
              value: local!noRenewalPagingInfo,
                  saveInto: {
            				a!save(
            				  local!noRenewalPagingInfo,
            				  if(
            					isnull(
            					  save!value.sort
            					),
            					local!noRenewalPagingInfo,
            					if(
            					  length(
            						save!value.sort.field
            					  ) <= 0,
            					  local!noRenewalPagingInfo,
            					  a!pagingInfo(
            						startIndex: save!value.startIndex,
            						batchSize: save!value.batchSize,
            						sort: a!sortInfo(
            						  field: save!value.sort.field,
            						  ascending: save!value.sort.ascending
            						)
            					 )
            					)
            				 )
            				)
          		 }
            )
          }
        )
        
    
      }
    
    )
    )
    )

  • 0
    Certified Senior Developer
    in reply to Josh
    Thanks! I suspected I may have to change the variable to a local variable. I did as suggested and it now displays in the Report menu but the contents don't update when the local!year_int variable is updated. How do I get the data to refresh?
  • 0
    Certified Lead Developer
    in reply to judym598
    Any variables in the load() context will not update whenever you change the value in local!year_int. For any values that need to be updated with local!year_int you can do one of two things: Either move those local variables into with() or copy them into the saveInto attribute where local!year_int is updated.
  • 0
    Certified Senior Developer
    in reply to Josh
    Took me a while to figure out how to do this but I did. It's working great now! Thanks so much for your help!!!
  • 0
    Certified Senior Developer
    in reply to judym598
    Got an additional issue now...Because I moved the local variables into with(), if the user clicks on a header row to resort the contents, I get an Expression Evaluation error:

    Expression evaluation error in rule 'psh_disapproveddashboard' at function a!gridField [line 48]: An error occurred while executing a save: Expression evaluation error: The save target must be a load() variable, process variable, or node input (or a rule input passed one of those three), but instead was: [startIndex=1, batchSize=25, sort=[field=name, ascending=true]]

    Is there a way to either disable the sort on the grid or fix it?

    Here's what I have now:

    =load(
    local!year_int: year(now())-5,
    with(
    local!noByItobProducts: rule!psh_getNoByItobProducts(datetime(local!year_int, month(now()), day(now()), 0, 0, 0)),
    local!noByItobProductsPagingInfo: a!pagingInfo(startIndex: 1, batchSize: 25, sort: a!sortInfo(field:"name", ascending: true)),
    local!noRenewAgreements: rule!psh_getNoRenewalAgreements(date(local!year_int, month(now()), day(now()))),
    local!noRenewalPagingInfo: a!pagingInfo(startIndex: 1, batchSize: 25, sort: a!sortInfo(field: "agreementDescription", ascending: true)),

    local!noByItobProductDataSubset: todatasubset(local!noByItobProducts, local!noByItobProductsPagingInfo),
    local!noRenewalDataSubset: todatasubset(local!noRenewAgreements, local!noRenewalPagingInfo),


    a!formLayout(
    label: "Disapproved Purchase Requests and Agreement Renewals",
    instructions: "Update Year Shown to Display Additional Items",
    contents: {
    a!sectionLayout(
    label: "",
    contents:{
    a!textField(
    label: "Disapproved Later Than:",
    labelPosition: "ADJACENT",
    value: local!year_int,
    saveInto: local!year_int,
    refreshAfter: "UNFOCUS"
    )
    }
    ),
    a!sectionLayout(
    label: "New Purchases Disapproved By ITOB",
    contents: {
    a!gridField(
    labelPosition: "ABOVE",
    totalCount: local!noByItobProductDataSubset.totalCount,
    columns: {
    a!gridTextColumn(
    label: "Product",
    field: "name",
    data: index(local!noByItobProductDataSubset.data, "name", null)),
    a!gridTextColumn(
    label: "Decided By",
    data: index(local!noByItobProductDataSubset.data, "decidedBy", null)),
    a!gridTextColumn(
    label: "ITOB Decision Date",
    data: index(local!noByItobProductDataSubset.data, "itobDateTime", null)),
    a!gridTextColumn(
    label: "Disapproval Reason",
    data: index(local!noByItobProductDataSubset.data, "itobFeedback", null))
    },
    value: local!noByItobProductsPagingInfo,
    saveInto: {
    a!save(
    local!noByItobProductsPagingInfo,
    if(
    isnull(
    save!value.sort
    ),
    local!noByItobProductsPagingInfo,
    if(
    length(
    save!value.sort.field
    ) <= 0,
    local!noByItobProductsPagingInfo,
    a!pagingInfo(
    startIndex: save!value.startIndex,
    batchSize: save!value.batchSize,
    sort: a!sortInfo(
    field: save!value.sort.field,
    ascending: save!value.sort.ascending
    )
    )
    )
    )
    )
    }
    )
    }
    ),

    a!sectionLayout(
    label: "Agreements Not Renewed",
    contents: {
    a!gridField(
    labelPosition: "ABOVE",
    totalCount: local!noRenewalDataSubset.totalCount,
    columns: {
    a!gridTextColumn(
    label: "Product",
    field:"agreementDescription",
    data: index(local!noRenewalDataSubset.data, "agreementDescription", null)
    ),
    a!gridTextColumn(
    label: "Submitted By",
    data: index(local!noRenewalDataSubset.data, "submittedBy", null)
    ),
    a!gridTextColumn(
    label: "Current Expiration Date",
    data: index(local!noRenewalDataSubset.data, "expiredDate", null)
    )
    },
    value: local!noRenewalPagingInfo,
    saveInto: {
    a!save(
    local!noRenewalPagingInfo,
    if(
    isnull(
    save!value.sort
    ),
    local!noRenewalPagingInfo,
    if(
    length(
    save!value.sort.field
    ) <= 0,
    local!noRenewalPagingInfo,
    a!pagingInfo(
    startIndex: save!value.startIndex,
    batchSize: save!value.batchSize,
    sort: a!sortInfo(
    field: save!value.sort.field,
    ascending: save!value.sort.ascending
    )
    )
    )
    )
    )
    }
    )
    }
    )


    }

    )
    )
    )
Reply
  • 0
    Certified Senior Developer
    in reply to judym598
    Got an additional issue now...Because I moved the local variables into with(), if the user clicks on a header row to resort the contents, I get an Expression Evaluation error:

    Expression evaluation error in rule 'psh_disapproveddashboard' at function a!gridField [line 48]: An error occurred while executing a save: Expression evaluation error: The save target must be a load() variable, process variable, or node input (or a rule input passed one of those three), but instead was: [startIndex=1, batchSize=25, sort=[field=name, ascending=true]]

    Is there a way to either disable the sort on the grid or fix it?

    Here's what I have now:

    =load(
    local!year_int: year(now())-5,
    with(
    local!noByItobProducts: rule!psh_getNoByItobProducts(datetime(local!year_int, month(now()), day(now()), 0, 0, 0)),
    local!noByItobProductsPagingInfo: a!pagingInfo(startIndex: 1, batchSize: 25, sort: a!sortInfo(field:"name", ascending: true)),
    local!noRenewAgreements: rule!psh_getNoRenewalAgreements(date(local!year_int, month(now()), day(now()))),
    local!noRenewalPagingInfo: a!pagingInfo(startIndex: 1, batchSize: 25, sort: a!sortInfo(field: "agreementDescription", ascending: true)),

    local!noByItobProductDataSubset: todatasubset(local!noByItobProducts, local!noByItobProductsPagingInfo),
    local!noRenewalDataSubset: todatasubset(local!noRenewAgreements, local!noRenewalPagingInfo),


    a!formLayout(
    label: "Disapproved Purchase Requests and Agreement Renewals",
    instructions: "Update Year Shown to Display Additional Items",
    contents: {
    a!sectionLayout(
    label: "",
    contents:{
    a!textField(
    label: "Disapproved Later Than:",
    labelPosition: "ADJACENT",
    value: local!year_int,
    saveInto: local!year_int,
    refreshAfter: "UNFOCUS"
    )
    }
    ),
    a!sectionLayout(
    label: "New Purchases Disapproved By ITOB",
    contents: {
    a!gridField(
    labelPosition: "ABOVE",
    totalCount: local!noByItobProductDataSubset.totalCount,
    columns: {
    a!gridTextColumn(
    label: "Product",
    field: "name",
    data: index(local!noByItobProductDataSubset.data, "name", null)),
    a!gridTextColumn(
    label: "Decided By",
    data: index(local!noByItobProductDataSubset.data, "decidedBy", null)),
    a!gridTextColumn(
    label: "ITOB Decision Date",
    data: index(local!noByItobProductDataSubset.data, "itobDateTime", null)),
    a!gridTextColumn(
    label: "Disapproval Reason",
    data: index(local!noByItobProductDataSubset.data, "itobFeedback", null))
    },
    value: local!noByItobProductsPagingInfo,
    saveInto: {
    a!save(
    local!noByItobProductsPagingInfo,
    if(
    isnull(
    save!value.sort
    ),
    local!noByItobProductsPagingInfo,
    if(
    length(
    save!value.sort.field
    ) <= 0,
    local!noByItobProductsPagingInfo,
    a!pagingInfo(
    startIndex: save!value.startIndex,
    batchSize: save!value.batchSize,
    sort: a!sortInfo(
    field: save!value.sort.field,
    ascending: save!value.sort.ascending
    )
    )
    )
    )
    )
    }
    )
    }
    ),

    a!sectionLayout(
    label: "Agreements Not Renewed",
    contents: {
    a!gridField(
    labelPosition: "ABOVE",
    totalCount: local!noRenewalDataSubset.totalCount,
    columns: {
    a!gridTextColumn(
    label: "Product",
    field:"agreementDescription",
    data: index(local!noRenewalDataSubset.data, "agreementDescription", null)
    ),
    a!gridTextColumn(
    label: "Submitted By",
    data: index(local!noRenewalDataSubset.data, "submittedBy", null)
    ),
    a!gridTextColumn(
    label: "Current Expiration Date",
    data: index(local!noRenewalDataSubset.data, "expiredDate", null)
    )
    },
    value: local!noRenewalPagingInfo,
    saveInto: {
    a!save(
    local!noRenewalPagingInfo,
    if(
    isnull(
    save!value.sort
    ),
    local!noRenewalPagingInfo,
    if(
    length(
    save!value.sort.field
    ) <= 0,
    local!noRenewalPagingInfo,
    a!pagingInfo(
    startIndex: save!value.startIndex,
    batchSize: save!value.batchSize,
    sort: a!sortInfo(
    field: save!value.sort.field,
    ascending: save!value.sort.ascending
    )
    )
    )
    )
    )
    }
    )
    }
    )


    }

    )
    )
    )
Children