Skip to main content
kavyam0002
May 9, 2022
Question

index invalid

  • May 9, 2022
  • 3 replies
  • 0 views

Hi when am trying to click on any button it is giving this error

even am able to print the data correctly 

here is the code 

 a!buttonWidget(
          label: cons!CR_APP_BUTTON_LABELS_FOR_CCC_USER[1],
          submit: true(),
          validate: false,
          value: cons!CR_APP_BUTTON_LABELS_FOR_CCC_USER[1],
          saveInto: {
            ri!buttonAction_txt,
            a!save(
              ri!nextAssignee_txt,
              local!crModuleStatusHistoryForLastCC_cdt.addedBy_txt
            ),
            a!save(
              ri!moduleStatus_txt,
              rule!CR_APP_FN_getNTBModuleStatus(
                inputUser_txt:local!crModuleStatusHistoryForLastCC_cdt.addedBy_txt
              )
            ),
            a!save(
              local!moduleRecommendationStatus_cdt,
              updatedictionary(
                local!moduleRecommendationStatus_cdt,
                {
                  approverRole_txt: rule!CR_APP_FN_getUserRole(
                    inputUser_txt: local!crModuleStatusHistoryForLastCC_cdt.addedBy_txt
                  ),
                  addedBy_txt: loggedInUser(),
                  moduleStatus_txt: cons!CR_APP_NTB_MODULE_STATUS[3],
                  buttonAction_txt: ri!buttonAction_txt,
                  updatedBy_txt: loggedInUser(),
                  updatedOn_dt: now(),
                  submittedOn_dt: now()
                }
              )
            ),
            a!save(
              ri!moduleRecommendationStatus_cdt,
              local!moduleRecommendationStatus_cdt
            ),
            a!save(
              local!crModuleStatus_cdt,
              updatedictionary(
                local!crModuleStatus_cdt,
                {
                  duOwner_txt: ri!nextAssignee_txt,
                  moduleStatus_txt: ri!moduleStatus_txt,
                  updatedOn_dt: now(),
                  updatedBy_txt: loggedInUser(),
                  updatedByRole_txt: rule!CR_APP_FN_getUserRole(
                    loggedInUser()
                  )
                }
              )
            ),
            a!save(
              local!crModuleStatus_cdt,
              updatedictionary(
                local!crModuleStatus_cdt,
                rule!CR_APP_FN_updateApprovedFlagsInModuleStatus(
                  buttonAction_txt: ri!buttonAction_txt
                )
              )
            ),
            a!save(
              ri!crModuleStatus_cdt,
              local!crModuleStatus_cdt
            )
          }
        ),
 

    3 replies

    ravir0014
    May 9, 2022

    Please check the local variable local!crModuleStatusHistoryForLastCC_cdt by adding a debug field. It must be empty (without any fields). That is why below code is breaking.

    a!save(
    ri!nextAssignee_txt,
    local!crModuleStatusHistoryForLastCC_cdt.addedBy_txt
    )

    If you use .(dot) operator, make sure your CDT is not empty.

    May 9, 2022

    I would suggest you to use the index() function for getting the values from your data structure and not direct dot notation when you are not sure about what your data type is returning.

    index(local!crModuleStatusHistoryForLastCC_cdt, "addedBy_txt", null)

    mikes0011
    Brainy
    May 9, 2022

    I agree with the above reply(s) that you should try to access the property of the local variable dictionary more safely than dot notation.  Though I still suggest, since you're not accessing an index (meaning a numbered position in an array) and rather accessing a (dot) property, i.e. dictionary/CDT field, that at least for code clarity you use the proper named function, which is property(), rather than index(), despite the fact that they are both aliases for identical back-end behavior.

    The Expression Guru