Adding rows to cdt

Hi Everyone,

I am getting the cdt rows through record type using expression rule. Is it possible to add more unique rows to cdt through expression rule. If yes, can anyone please help me out?

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Senior Developer

    Hi ,

    you are currently retrieving existing CDT data via a record type using an expression rule.. To add new unique rows to this CDT, you can use the append() function within an expression rule to add new data to your existing dataset.

    Steps:

    1. Retrieve Existing Data: Use an expression rule to get the current rows of data from the CDT through the record type. Let's assume this data is stored in a local variable called local!existingData.

    2. Create New Row Data: Define the new row data that you want to add to your CDT. This should match the structure of your CDT. For example:

                 local!newRow := {
                 field1: "New Value 1",
                 field2: "New Value 2",
                 ...
                 fieldN: "New Value N"
                 }

              3.Add Row to Existing Data: Use the append() function to add your new row to the existing dataset:

              local!updatedData := append(local!existingData, local!newRow)

             Save it.

    Example:

    a!localVariables(
    local!existingData: /* Your expression to retrieve existing CDT data */,
    local!newRow: /* Define the new row data here */,
    local!updatedData: append(local!existingData, local!newRow),
    {
    /* Your interface elements go here, such as a grid or form to display local!existingData */
    /* Use a button or another interface component to trigger the save of local!updatedData */
    }
    )

Reply
  • 0
    Certified Senior Developer

    Hi ,

    you are currently retrieving existing CDT data via a record type using an expression rule.. To add new unique rows to this CDT, you can use the append() function within an expression rule to add new data to your existing dataset.

    Steps:

    1. Retrieve Existing Data: Use an expression rule to get the current rows of data from the CDT through the record type. Let's assume this data is stored in a local variable called local!existingData.

    2. Create New Row Data: Define the new row data that you want to add to your CDT. This should match the structure of your CDT. For example:

                 local!newRow := {
                 field1: "New Value 1",
                 field2: "New Value 2",
                 ...
                 fieldN: "New Value N"
                 }

              3.Add Row to Existing Data: Use the append() function to add your new row to the existing dataset:

              local!updatedData := append(local!existingData, local!newRow)

             Save it.

    Example:

    a!localVariables(
    local!existingData: /* Your expression to retrieve existing CDT data */,
    local!newRow: /* Define the new row data here */,
    local!updatedData: append(local!existingData, local!newRow),
    {
    /* Your interface elements go here, such as a grid or form to display local!existingData */
    /* Use a button or another interface component to trigger the save of local!updatedData */
    }
    )

Children
No Data