Update to table in database

Hi All

a!localVariables(
  local!crFeesComments_cdt: rule!CR_FN_getModuleComments(
    crModuleComments: ri!crModuleComments_cdt,
    commentId_int: cons!CR_AS_COMMENT_IDS[1]
  ),
  local!crPricingApprovalComments_cdt: rule!CR_FN_getModuleComments(
    crModuleComments: ri!crModuleComments_cdt,
    commentId_int: cons!CR_AS_COMMENT_IDS[2]
  ),
  local!crFxRatesBuy_cdt: index(
    ri!crFxRatesFromDb_cdt,
    wherecontains(
      { 1, 2, 3 },
      index(
        ri!crFxRatesFromDb_cdt,
        "seqNumber_int",
        {}
      )
    ),
    {}
  ),
  local!crFxRatesSell_cdt: index(
    ri!crFxRatesFromDb_cdt,
    wherecontains(
      { 4, 5, 6 },
      index(
        ri!crFxRatesFromDb_cdt,
        "seqNumber_int",
        {}
      )
    ),
    {}
  ),
  {
    rule!CR_RT_displayInformativeNote(
      pageName_txt: cons!CR_TXT_SECTION_NAMES_TODISPLAY_AMOUNT[3]
    ),
    rule!CR_SC_AS_displayROCOverview(
      cif_int: ri!cif_int,
      systemRequestId_int: ri!systemRequestId_int,
      crRocOverview_cdt: ri!crRocOverview_cdt
    ),
    rule!CR_SC_AS_displayFeeDetails(
      isReadOnly_bool: ri!isReadOnly_bool,
      isActive_bool: ri!isActive_bool,
      crFeeDetails_cdt: ri!crFeeDetails_cdt
    ),
    rule!CR_RTF_UI_displayRichTextFieldEditorComponent(
      moduleId_int: ri!moduleId_int,
      crModuleComments_cdt: ri!crModuleComments_cdt,
      placeHolder_txt: { "please enter value" },
      cif_int: ri!cif_int,
      commentId_int: cons!CR_AS_COMMENT_IDS[1],
      instructions_txt: null,
      isReadOnly_bool: ri!isReadOnly_bool,
      inputComment_cdt: local!crFeesComments_cdt,
      requestId_int: ri!requestId_int,
      role_txt: ri!role_txt,
      label_txt: cons!CR_LAB_COMMENT,
      isRequired_bool: false(),
      value_txt: clean(
        rule!CR_APP_FN_cleanRichTextEditorString(
          index(
            rule!CR_FN_getModuleComments(
              crModuleComments: ri!crModuleComments_cdt,
              commentId_int: cons!CR_AS_COMMENT_IDS[1]
            ),
            "comment_txt",
            {}
          )
        )
      ),
      helpTooltip_txt: null,
      
    ),
    rule!CR_SC_AS_displayFXRates(
      isReadOnly_bool: ri!isReadOnly_bool,
      isActive_bool: ri!isActive_bool,
      crFxRatesBuy_cdt: local!crFxRatesBuy_cdt,
      crFxRatesSell_cdt: local!crFxRatesSell_cdt,
      preffered_txt: ri!preffered_txt
    ),
    rule!CR_SC_AS_displayTariffBanding(
      isReadOnly_bool: ri!isReadOnly_bool,
      crTariffBanding_cdt: ri!crTariffBanding_cdt
    ),
    rule!CR_SC_AS_displayPricingDetails(
      cif_int: ri!cif_int,
      isReadOnly_bool: ri!isReadOnly_bool,
      requestId_int: ri!requestId_int,
      crPricingApprovals_cdt: ri!crPricingApprovals_cdt,
      uploadedDocIds_int: ri!uploadedDocIds_int,
      moduleId_int: ri!moduleId_int,
      isDashboard_bool: ri!isDashboard_bool
    ),
    rule!CR_RTF_UI_displayRichTextFieldEditorComponent(
      moduleId_int: ri!moduleId_int,
      crModuleComments_cdt: ri!crModuleComments_cdt,
      placeHolder_txt: { "please enter value" },
      cif_int: ri!cif_int,
      commentId_int: cons!CR_AS_COMMENT_IDS[2],
      instructions_txt: null,
      isReadOnly_bool: ri!isReadOnly_bool,
      inputComment_cdt: local!crPricingApprovalComments_cdt,
      requestId_int: ri!requestId_int,
      role_txt: ri!role_txt,
      label_txt: cons!CR_LAB_COMMENT,
      isRequired_bool: ri!isActive_bool,
      value_txt: clean(
        rule!CR_APP_FN_cleanRichTextEditorString(
          index(
            rule!CR_FN_getModuleComments(
              crModuleComments: ri!crModuleComments_cdt,
              commentId_int: cons!CR_AS_COMMENT_IDS[2]
            ),
            "comment_txt",
            {}
          )
        )
      ),
      helpTooltip_txt: rule!CR_DSC_getAccountStrategyToolTipsByFields(
        FieldName: cons!CR_LAB_ACCOUNT_STRATEGY_ALL_FIELDS[6]
      )
    ),
    a!columnsLayout(
      showWhen: if(
        rule!APN_isBlank(ri!isReadOnly_bool),
        true,
        not(ri!isReadOnly_bool)
      ),
      columns: {
        a!columnLayout(
          width: "AUTO",
          contents: {
            rule!CR_UI_displayMessageCard(save_dt: ri!save_dt)
          }
        ),
        a!columnLayout(
          width: "NARROW",
          contents: {
            a!buttonArrayLayout(
              align: "END",
              buttons: {
                a!buttonWidget(
                  label: cons!APN_TXT_SAVE_DRAFT,
                  value: cons!APN_TXT_SAVE,
                  submit: true(),
                  saveInto: {
                    a!save(
                      ri!buttonAction_txt,
                      cons!APN_TXT_SAVE_DRAFT
                    ),
                    a!save(
                      ri!crFxRatesFromDb_cdt,
                      local!crFxRatesBuy_cdt
                    ),
                    a!save(
                      ri!crFxRatesFromDb_cdt,
                      append(
                        ri!crFxRatesFromDb_cdt,
                        local!crFxRatesSell_cdt
                      )
                    ),
                    rule!CR_FN_storeModuleStatusHistory(
                      moduleRecommendationStatus_cdt: ri!moduleRecommendationStatus_cdt,
                      requestId_int: ri!requestId_int,
                      cif_int: ri!cif_int,
                      role_txt: ri!role_txt,
                      originalExpiry_dt: ri!originalExpiry_dt,
                      moduleStatus_txt: cons!CR_AS_MODULE_STATUS[1],
                      crModuleStatusHistory_cdt: ri!crModuleStatusHistory_cdt,
                      moduleId_int: ri!moduleId_int,
                      workflowId_int: ri!workflowId_int,
                      buttonAction_txt: cons!APN_TXT_SAVE_DRAFT,
                      currentNetROC_dec: ri!crRocOverview_cdt.currentNetRoc_dec
                    ),
                    rule!CR_FN_AS_storeFeeDetails(
                      crFeeDetails_cdt: ri!crFeeDetails_cdt,
                      requestId_int: ri!requestId_int,
                      cif_int: ri!cif_int,
                      moduleId_int: ri!moduleId_int
                    ),
                    rule!CR_FN_AS_storeFXRates(
                      crFxRatesFromDb_cdt: ri!crFxRatesFromDb_cdt
                    ),
                    rule!CR_FN_AS_storeTariffBanding(
                      crTariffBanding_cdt: ri!crTariffBanding_cdt
                    ),
                    rule!CR_FN_AS_storePricingApprovals(
                      crPricingApprovals_cdt: ri!crPricingApprovals_cdt
                    ),
                    a!save(
                      ri!docSectionName_txt,
                      cons!CR_AS_SECTION_NAME[1]
                    ),
                    a!writeToMultipleDataStoreEntities(
                      valuesToStore: {
                        a!entityData(
                          entity: cons!CR_ENTITY_MODULE_COMMENTS,
                          data: ri!crModuleComments_cdt
                        ),
                        a!entityData(
                          entity: cons!CR_ENTITY_MODULE_STATUS_HISTORY,
                          data: ri!crModuleStatusHistory_cdt
                        ),
                        a!entityData(
                          entity: cons!CR_ENTITY_AS_FEE_DETAILS,
                          data: ri!crFeeDetails_cdt
                        ),
                        a!entityData(
                          entity: cons!CR_ENTITY_AS_FX_RATES,
                          data: ri!crFxRatesFromDb_cdt
                        ),
                        a!entityData(
                          entity: cons!CR_ENTITY_AS_TARIFF_BANDING,
                          data: ri!crTariffBanding_cdt
                        ),
                        a!entityData(
                          entity: cons!CR_ENTITY_AS_PRICING_APPROVALS,
                          data: ri!crPricingApprovals_cdt
                        )
                      },
                      onSuccess: {
                        a!save(
                          ri!crModuleComments_cdt,
                          index(fv!storedValues, 1, "data", {})
                        ),
                        a!save(
                          ri!crModuleStatusHistory_cdt,
                          index(fv!storedValues, 2, "data", {})
                        ),
                        a!save(
                          ri!crFeeDetails_cdt,
                          index(fv!storedValues, 3, "data", {})
                        ),
                        a!save(
                          ri!crFxRatesFromDb_cdt,
                          index(fv!storedValues, 4, "data", {})
                        ),
                        a!save(
                          ri!crTariffBanding_cdt,
                          index(fv!storedValues, 5, "data", {})
                        ),
                        a!save(
                          ri!crPricingApprovals_cdt,
                          index(fv!storedValues, 6, "data", {})
                        ),
                        a!save(
                          ri!moduleRecommendationStatus_cdt,
                          rule!CR_FN_getModuleStatusHistoryByStatus(
                            crModuleStatusHistory_cdt: ri!crModuleStatusHistory_cdt
                          )
                        ),
                        a!save(
                          local!crFeesComments_cdt,
                          rule!CR_FN_getModuleComments(
                            crModuleComments: ri!crModuleComments_cdt,
                            commentId_int: cons!CR_AS_COMMENT_IDS[1]
                          )
                        ),
                        a!save(
                          local!crPricingApprovalComments_cdt,
                          rule!CR_FN_getModuleComments(
                            crModuleComments: ri!crModuleComments_cdt,
                            commentId_int: cons!CR_AS_COMMENT_IDS[2]
                          )
                        ),
                        a!save(ri!save_dt, now())
                      }
                    )
                  },
                  style: "NORMAL",
                  validate: false()
                ),
                a!buttonWidget(
                  label: cons!APN_TXT_SAVE,
                  value: cons!APN_TXT_SAVE,
                  submit: true(),
                  saveInto: {
                    a!save(ri!buttonAction_txt, cons!APN_TXT_SAVE),
                    a!save(
                      ri!crFxRatesFromDb_cdt,
                      local!crFxRatesBuy_cdt
                    ),
                    a!save(
                      ri!crFxRatesFromDb_cdt,
                      append(
                        ri!crFxRatesFromDb_cdt,
                        local!crFxRatesSell_cdt
                      )
                    ),
                    rule!CR_FN_storeModuleStatusHistory(
                      moduleRecommendationStatus_cdt: ri!moduleRecommendationStatus_cdt,
                      requestId_int: ri!requestId_int,
                      cif_int: ri!cif_int,
                      role_txt: ri!role_txt,
                      originalExpiry_dt: ri!originalExpiry_dt,
                      moduleStatus_txt: cons!CR_AS_MODULE_STATUS[1],
                      crModuleStatusHistory_cdt: ri!crModuleStatusHistory_cdt,
                      moduleId_int: ri!moduleId_int,
                      workflowId_int: ri!workflowId_int,
                      buttonAction_txt: cons!APN_TXT_SAVE,
                      currentNetROC_dec: ri!crRocOverview_cdt.currentNetRoc_dec
                    ),
                    rule!CR_FN_AS_storeFeeDetails(
                      crFeeDetails_cdt: ri!crFeeDetails_cdt,
                      requestId_int: ri!requestId_int,
                      cif_int: ri!cif_int,
                      moduleId_int: ri!moduleId_int
                    ),
                    rule!CR_FN_AS_storeFXRates(
                      crFxRatesFromDb_cdt: ri!crFxRatesFromDb_cdt
                    ),
                    rule!CR_FN_AS_storeTariffBanding(
                      crTariffBanding_cdt: ri!crTariffBanding_cdt
                    ),
                    rule!CR_FN_AS_storePricingApprovals(
                      crPricingApprovals_cdt: ri!crPricingApprovals_cdt
                    ),
                    a!save(
                      ri!docSectionName_txt,
                      cons!CR_AS_SECTION_NAME[1]
                    ),
                    a!writeToMultipleDataStoreEntities(
                      valuesToStore: {
                        a!entityData(
                          entity: cons!CR_ENTITY_MODULE_COMMENTS,
                          data: ri!crModuleComments_cdt
                        ),
                        a!entityData(
                          entity: cons!CR_ENTITY_MODULE_STATUS_HISTORY,
                          data: ri!crModuleStatusHistory_cdt
                        ),
                        a!entityData(
                          entity: cons!CR_ENTITY_AS_FEE_DETAILS,
                          data: ri!crFeeDetails_cdt
                        ),
                        a!entityData(
                          entity: cons!CR_ENTITY_AS_FX_RATES,
                          data: ri!crFxRatesFromDb_cdt
                        ),
                        a!entityData(
                          entity: cons!CR_ENTITY_AS_TARIFF_BANDING,
                          data: ri!crTariffBanding_cdt
                        ),
                        a!entityData(
                          entity: cons!CR_ENTITY_AS_PRICING_APPROVALS,
                          data: ri!crPricingApprovals_cdt
                        )
                      },
                      onSuccess: {
                        a!save(
                          ri!crModuleComments_cdt,
                          index(fv!storedValues, 1, "data", {})
                        ),
                        a!save(
                          ri!crModuleStatusHistory_cdt,
                          index(fv!storedValues, 2, "data", {})
                        ),
                        a!save(
                          ri!crFeeDetails_cdt,
                          index(fv!storedValues, 3, "data", {})
                        ),
                        a!save(
                          ri!crFxRatesFromDb_cdt,
                          index(fv!storedValues, 4, "data", {})
                        ),
                        a!save(
                          ri!crTariffBanding_cdt,
                          index(fv!storedValues, 5, "data", {})
                        ),
                        a!save(
                          ri!crPricingApprovals_cdt,
                          index(fv!storedValues, 6, "data", {})
                        ),
                        a!save(
                          ri!moduleRecommendationStatus_cdt,
                          rule!CR_FN_getModuleStatusHistoryByStatus(
                            crModuleStatusHistory_cdt: ri!crModuleStatusHistory_cdt
                          )
                        ),
                        a!save(
                          local!crFeesComments_cdt,
                          rule!CR_FN_getModuleComments(
                            crModuleComments: ri!crModuleComments_cdt,
                            commentId_int: cons!CR_AS_COMMENT_IDS[1]
                          )
                        ),
                        a!save(
                          local!crPricingApprovalComments_cdt,
                          rule!CR_FN_getModuleComments(
                            crModuleComments: ri!crModuleComments_cdt,
                            commentId_int: cons!CR_AS_COMMENT_IDS[2]
                          )
                        ),
                        a!save(ri!save_dt, now())
                      }
                    )
                  },
                  style: "NORMAL",
                  validate: true
                )
              }
            )
          }
        )
      }
    )
  }
)

I am trying to update one value to the table ,Field name is preferred_txt created in child UI called in the code which is pasted above .

I need to write that preferred_txt value to the db on save and save draft buttons. How can i do that please let me know the solution.

note: preferred_txt is a dropdown value.

 that preferred_txt is called here in the above code .Let me know if anybody has questions and please give me the solution ASAP.

Thanks in advance

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    Yeah ... well, I already see some write to datastore calls in your button. So my question is: What is going wrong? Do you have any specific issue?

  • Yeah I have one issue.

    I am trying append preffered_txt to cdt that is

     a!save(
    ri!crFxRatesFromDb_cdt,
    ri!preffered_txt
    ),

    But getting this error -Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error [evaluation ID = 3R3L0] in rule 'cr_sc_as_capturereturnsandpricingdetails' : An error occurred while executing a save: Could not cast from Text to CR_AS_FXRates. Details: CastInvalid.  How to append text to the cdt?

  • Reason why I am following up that approach bcoz I want to update dropdown value to cdt.Here crFxRatesSell_cdt and crFxRatesBuy_cdt are belongs to same table. I have to update the dropdown(Single selection value) value that is preferredRate_txt to same table . How would i do that ?  Any different approach?

    a!cardLayout(
      contents: {
        a!columnsLayout(
          columns: {
            a!columnLayout(
              contents: {
                a!dropdownField(
                  placeholder: "SELECT",
                  label: cons!CR_LAB_ACCOUNT_STRATEGY_ALL_FIELDS[22],
                  choiceLabels: cons!CR_APP_TXT_CHOICE_LABELS_T0_T1_T2,
                  choiceValues: cons!CR_APP_TXT_CHOICE_LABELS_T0_T1_T2,
                  value: ri!preffered_txt,
                  saveInto: ri!preffered_txt,
                  disabled: ri!isReadOnly_bool,
                  
                )
              },
              width: "NARROW"
            )
          }
        ),
        rule!CR_RT_displayRichTextHeader(
          /*"FX Rates"*/
          input_txt: cons!CR_LAB_ACCOUNT_STRATEGY_ALL_FIELDS[4],
          caption_txt: rule!CR_DSC_getAccountStrategyToolTipsByFields(
            FieldName: cons!CR_LAB_ACCOUNT_STRATEGY_ALL_FIELDS[4]
          )
        ),
        a!columnsLayout(
          columns: {
            a!columnLayout(
              contents: {
                a!gridLayout(
                  /*label: "FX Rates",*/
                  labelPosition: "COLLAPSED",
                  spacing: "DENSE",
                  headerCells: {
                    a!forEach(
                      items: cons!CR_GD_LABEL_FX_RATES,
                      expression: a!gridLayoutHeaderCell(
                        label: if(
                          contains(3, fv!index),
                          fv!item & cons!CR_TXT_DISPLAY_ASTERISK,
                          fv!item
                        ),
                        align: if(
                          contains({ 2, 3 }, fv!index),
                          "RIGHT",
                          "LEFT"
                        )
                      )
                    )
                  },
                  columnConfigs: {
                    a!forEach(
                      items: cons!CR_GD_LABEL_FX_RATES,
                      expression: a!gridLayoutColumnConfig(
                        width: if(fv!isFirst, "NARROW", "DISTRIBUTE")
                      )
                    )
                  },
                  rows: {
                    a!forEach(
                      items: ri!crFxRatesSell_cdt,
                      expression: a!gridRowLayout(
                        contents: {
                          a!textField(
                            readOnly: true(),
                            value: fv!item.tariffType_txt
                          ),
                          a!textField(
                            align: "RIGHT",
                            readOnly: true(),
                            value: rule!CR_FN_setDecimalValues(
                              value_dec: fv!item.tariffAmountExisting_dec,
                              decPlace_int: 4
                            )
                          ),
                          a!textField(
                            align: "RIGHT",
                            required: ri!isActive_bool,
                            value: rule!CR_FN_setDecimalValues(
                              value_dec: fv!item.tariffAmountProposed_dec,
                              decPlace_int: 4
                            ),
                            validations: rule!CR_FN_setMaximumNumberValidation(
                              value_dec: fv!item.tariffAmountProposed_dec,
                              maxLength_int: 10
                            ),
                            saveInto: {
                              fv!item.tariffAmountProposed_dec,
                              a!save(
                                fv!item.preferredRate_txt,
                                ri!preffered_txt
                              )
                            },
                            disabled: ri!isReadOnly_bool
                          )
                        }
                      )
                    )
                  }
                )
              }
            ),
            a!columnLayout(
              contents: {
                a!gridLayout(
                  /*label: "FX Rates",*/
                  labelPosition: "COLLAPSED",
                  spacing: "DENSE",
                  headerCells: {
                    a!forEach(
                      items: cons!CR_GD_LABEL_FX_RATES,
                      expression: a!gridLayoutHeaderCell(
                        label: if(
                          contains(3, fv!index),
                          fv!item & cons!CR_TXT_DISPLAY_ASTERISK,
                          fv!item
                        ),
                        align: if(
                          contains({ 2, 3 }, fv!index),
                          "RIGHT",
                          "LEFT"
                        )
                      )
                    )
                  },
                  columnConfigs: {
                    a!forEach(
                      items: cons!CR_GD_LABEL_FX_RATES,
                      expression: a!gridLayoutColumnConfig(
                        width: if(fv!isFirst, "NARROW", "DISTRIBUTE")
                      )
                    )
                  },
                  rows: {
                    a!forEach(
                      items: ri!crFxRatesBuy_cdt,
                      expression: a!gridRowLayout(
                        contents: {
                          a!textField(
                            readOnly: true(),
                            value: fv!item.tariffType_txt
                          ),
                          a!textField(
                            align: "RIGHT",
                            readOnly: true(),
                            value: rule!CR_FN_setDecimalValues(
                              value_dec: fv!item.tariffAmountExisting_dec,
                              decPlace_int: 4
                            )
                          ),
                          a!textField(
                            align: "RIGHT",
                            required: ri!isActive_bool,
                            value: rule!CR_FN_setDecimalValues(
                              value_dec: fv!item.tariffAmountProposed_dec,
                              decPlace_int: 4
                            ),
                            validations: rule!CR_FN_setMaximumNumberValidation(
                              value_dec: fv!item.tariffAmountProposed_dec,
                              maxLength_int: 10
                            ),
                            saveInto: {
                              fv!item.tariffAmountProposed_dec,
                              a!save(
                                fv!item.preferredRate_txt,
                                ri!preffered_txt
                              )
                            },
                            disabled: ri!isReadOnly_bool
                          )
                        }
                      )
                    )
                  }
                )
              }
            )
          },
          spacing: "NONE"
        )
      },
      style: "NONE",
      height: "AUTO",
      marginBelow: "STANDARD"
    )

  • 0
    Certified Lead Developer
    in reply to JS0001

    When I try to append something, I use the append() function. Did you try that?

    When things do not work for me, I try to replicate the challenge in isolation in a separate expression. Once I understand how to achieve my goal, I merge that code, or just the solution, into my final solution.

Reply Children
No Data