how to remove the empty rows from CDT before inserting in to Data base?

Certified Senior Developer

Hi,

We have requirement to use editable grid to add/delete/edit rows into CDT. Noting was mandatory from the Interface. where as while writing to DB some of them are NOT NULL columns.

User can submit the empty rows by clicking the Add link in editable grid. Write to Data Store throws an exception because Null values.

how to remove the empty rows from the CDT before giving to Write to Data Store.

Or At least from the interface it self to delete the empty rows before submitting the form.

Working example will help to solve this ASAP.

Thanks in Advance.

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer
    Hi,

    You can use below code to remove any empty rows from CDT.In my case i have assumed ID as primary key.
    load(
    local!nullCdt:{{id:1,name:"abc",dep:"def"};{id:2,name:"abc",dep:"def"};
    {id:"",name:"",dep:""}},
    local!removedNull:a!forEach(items:local!nullCdt,
    expression: if(isnull(fv!item.id),{},fv!item)),
    local!removedNull
    )

    Thanks,
    Nitesh
Reply
  • 0
    Certified Lead Developer
    Hi,

    You can use below code to remove any empty rows from CDT.In my case i have assumed ID as primary key.
    load(
    local!nullCdt:{{id:1,name:"abc",dep:"def"};{id:2,name:"abc",dep:"def"};
    {id:"",name:"",dep:""}},
    local!removedNull:a!forEach(items:local!nullCdt,
    expression: if(isnull(fv!item.id),{},fv!item)),
    local!removedNull
    )

    Thanks,
    Nitesh
Children
No Data