add row

whenever i click on add it's creating blank row in in RI, but no in the interface 

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    Can you share your code here are you using for loop to display rows?

    check line number 15

    a!localVariables(
      local!items: {
        { item: "Item 1", qty: 1, unitPrice: 10 },
        { item: "Item 2", qty: 2, unitPrice: 20 }
      },
      a!gridLayout(
        label: "Products",
        instructions: "Update the item name, quantity, or unit price.",
        headerCells: {
          a!gridLayoutHeaderCell(label: "Item"),
          a!gridLayoutHeaderCell(label: "Qty"),
          a!gridLayoutHeaderCell(label: "Unit Price"),
          a!gridLayoutHeaderCell(label: "Total", align: "RIGHT")
        },
        rows: a!forEach( /* loop to show all rows*/
          items: local!items,
          expression: a!gridRowLayout(
            contents: {
              a!textField(
                value: fv!item.item,
                saveInto: fv!item.item
              ),
              a!integerField(value: fv!item.qty, saveInto: fv!item.qty),
              a!floatingPointField(
                value: fv!item.unitPrice,
                saveInto: fv!item.unitPrice
              ),
              a!textField(
                value: tointeger(fv!item.qty) * todecimal(fv!item.unitPrice),
                readOnly: true,
                align: "RIGHT"
              )
            }
          )
        ),
        rowHeader: 1,
        addRowLink: a!dynamicLink(
          label: "Add row",
          saveInto: a!save(
            local!items,
            append(
              local!items,
              { item: null, qty: null, unitPrice: null }
            )
          )
        )
      )
    )a!localVariables(
      local!items: {
        { item: "Item 1", qty: 1, unitPrice: 10 },
        { item: "Item 2", qty: 2, unitPrice: 20 }
      },
      a!gridLayout(
        label: "Products",
        instructions: "Update the item name, quantity, or unit price.",
        headerCells: {
          a!gridLayoutHeaderCell(label: "Item"),
          a!gridLayoutHeaderCell(label: "Qty"),
          a!gridLayoutHeaderCell(label: "Unit Price"),
          a!gridLayoutHeaderCell(label: "Total", align: "RIGHT")
        },
        rows: a!forEach( /* loop to show all rows*/
          items: local!items,
          expression: a!gridRowLayout(
            contents: {
              a!textField(
                value: fv!item.item,
                saveInto: fv!item.item
              ),
              a!integerField(value: fv!item.qty, saveInto: fv!item.qty),
              a!floatingPointField(
                value: fv!item.unitPrice,
                saveInto: fv!item.unitPrice
              ),
              a!textField(
                value: tointeger(fv!item.qty) * todecimal(fv!item.unitPrice),
                readOnly: true,
                align: "RIGHT"
              )
            }
          )
        ),
        rowHeader: 1,
        addRowLink: a!dynamicLink(
          label: "Add row",
          saveInto: a!save(
            local!items,
            append(
              local!items,
              { item: null, qty: null, unitPrice: null }
            )
          )
        )
      )
    )

  • Pass your Ri (crAPPContractExtension_cdt) in the items parameter of the a!forEach() function. 

  • see i have written the same code

    but still it is not creating the row instead their are 13 rows it has created 13 rows by default

  • 0
    Certified Lead Developer
    in reply to KM

    Okay check that you are using a different variable for looping and when you are adding a new row you are using a different rule input. I think they should be same.

    rule input you are using for looping.

    rule input in which you are adding a new row.

  • yes, from that getcontractid_cdt am fetching data to show the in dropdown.

    once i save that dropdown that values has to be stored in contractsaved_cdt and whenever add row that has to be added to contractsaved_cdt

    to below the added row should show the same values what it has shown at the first time(i mean same dropdown values to be shown)

  • +1
    Certified Lead Developer
    in reply to KM

    But why you want to use getcontractid_cdt  for looping?

    And I am not getting why you want to run loop over dropdown values you can show all your dropdown values using choice labels and choice values and to add new data and save it you can use contractsaved_cdt directly and run the loop over it 

  • yes, i corrected it.. it's working fine now. but am getting error in dropdown

    when i select value for the dropdown am getting error 

     could see the values but when i select it it's giving error

  • +1
    Certified Lead Developer
    in reply to KM

    Now the variable which you are using to store the id is of type integer and that is ignoring the text value while storing so to get rid of this change the data type of your contractId_int.

    If it works for you always verify the answers so that other community members can also know you problem is resolved.