How to re-initialize the local variable which is created while start of the expression rule? and how to execute a block of code in the 'Else' part of the 'If' condition.

Hi,

1) May I know how to change or re-initialize the local variable which has been initialized in the starting of the expression rule. (I have marked the local variable which needs to be re-initialized in 'Green' color).

2) Also may I know how to execute queryentity or execute a block of code in the 'Else' part of the 'If' condition. (I have marked the block of code which needs to be executed in the 'Else' part of 'If' condition in 'Yellow' color)

load(
  local!QuoteDetails: null,
  local!quoteSection: tointeger({}),
  if(
    ri!action = "Start",
    cons!QUOTE_UI_ROUTE_NAMES[3],
    {
      local!QuoteDetails: a!queryEntity(
        cons!MONITOR_QUOTE_SECTION,
        a!query(
          selection: a!querySelection(
            columns: {
              a!queryColumn(
                field: "Quote_Section"
              ),
              a!queryColumn(
                field: "Created_On"
              )
            }
          ),
          filter: a!queryFilter(
            "Policy_Id",
            "=",
            if(
              ri!policyId = "",
              0,
              ri!policyId
            )
          ),
          pagingInfo: a!pagingInfo(
            startIndex: 1,
            batchSize: 1,
            sort: a!sortInfo(
              "Created_On",
              false()
            )
          )
        )
      ).data,
      local!quoteSection: index(
        local!QuoteDetails,
        "Quote_Section",
        ""
      ),
      if(
        isnull(
          local!quoteSection
        ),
        cons!QUOTE_UI_ROUTE_NAMES[1],
        cons!QUOTE_UI_ROUTE_NAMES[local!quoteSection]
      )
    }
  )
)


Regards,

Balaji.R

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer
    Hi Balaji,

    If you want to reset the value of the local variable conditionally, you could do either of the following, based on the use case.

    1) Using with() as Mike Mentioned - But we need to be more careful with respect to performance.
    2) Set the value in the saveInto of a particular field

    It seems you wanted to reset the local!QuoteDetails based on ri!action value.

    So, you can call your executed part in the saveInto of the field where you are capturing ri!action.
Reply
  • 0
    Certified Lead Developer
    Hi Balaji,

    If you want to reset the value of the local variable conditionally, you could do either of the following, based on the use case.

    1) Using with() as Mike Mentioned - But we need to be more careful with respect to performance.
    2) Set the value in the saveInto of a particular field

    It seems you wanted to reset the local!QuoteDetails based on ri!action value.

    So, you can call your executed part in the saveInto of the field where you are capturing ri!action.
Children