=load( /* Needed when adding or removing items via a!applyComponents `*/ local!itemsToken, a!formLayout( label: "SAIL Example: Inline Editable Grid Using a CDT", firstColumnContents: { a!gridLayout( headerCells: { a!gridLayoutHeaderCell(label: "Text"), a!gridLayoutHeaderCell(label: "Integer", align: "RIGHT"), a!gridLayoutHeaderCell(label: "Date", align: "RIGHT"), /* For the "Remove" column */ a!gridLayoutHeaderCell(label: "") }, /* Only needed when some columns need to be narrow */ columnConfigs: { a!gridLayoutColumnConfig(width: "DISTRIBUTE"), a!gridLayoutColumnConfig(width: "DISTRIBUTE"), a!gridLayoutColumnConfig(width: "DISTRIBUTE"), a!gridLayoutColumnConfig(width: "NARROW") }, rows: a!applyComponents( function: rule!uc_itemRowEach( items: ri!sampleCDT, index: _, itemsToken: local!itemsToken ), array: if(or(isnull(ri!sampleCDT), count(ri!sampleCDT) < 1), {}, 1+enumerate(count(ri!sampleCDT))), arrayVariable: local!itemsToken ) ), a!linkField( label: "Add Link", labelPosition: "COLLAPSED", links: a!dynamicLink( label: "+Add Item", /* * For your use case, set the value to a blank instance of your CDT using * the type constructor, e.g. type!PurchaseRequestItem(). Only specify the field * if you want to give it a default value e.g. due: today()+1. */ value: type!CDT_editableGrid(), saveInto: { a!save(ri!sampleCDT, append(ri!sampleCDT, save!value)), /*` When modifying the size of the array used in a!applyComponents, */ /* make the same change in the "token" array variable */ a!save(local!itemsToken, append(local!itemsToken, save!value)) } ) ) }, buttons: a!buttonLayout( primaryButtons: a!buttonWidgetSubmit( label: "Submit" ) ) ) )