Unable to add row dynamically .

Hi ,

I have a nested cdt . When i try to add a row dynamically to the grid i am unable to do it . I want it to be save in this format ,--- Details : ABC , CDF   Department : depatment type: CSE , createdby : loggedin user, date:now().

 And here ri!doc - is rule input with any type .

Can anyone help me with it please. Below is the code. Thank you in advance .

a!localVariables(

local!employeesDoc: cast(
'type!{urn:com:appian:types:AA}AA_Vehicaledata',
{
Details: null,
department:{
departmenttype:
createdby:loggedInUser(),
dateCreated:now()
},
}
),



a!formLayout(
label: "Example: Add,Update, or Remove Employee Data",
contents: {
a!gridLayout(

headerCells: {
a!gridLayoutHeaderCell(label: "Name" ),
a!gridLayoutHeaderCell(label: "Department" ),
a!gridLayoutHeaderCell(label: "created by" ),
a!gridLayoutHeaderCell(label: " created date" ),


a!gridLayoutHeaderCell(label: "" )
},

columnConfigs: {
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),

},

rows: a!gridRowLayout(
contents: {


a!fileUploadField(

value: local!employeesDoc.Details,
saveInto: local!employeesDoc.Details,

),
/* For the Department Column*/
a!dropdownField(

placeholder: "-- Select -- ",
choiceLabels: { "Corporate", "Engineering", "Finance", "Human Resources", "Professional Services", "Sales" },
choiceValues: { "Corporate", "Engineering", "Finance", "Human Resources", "Professional Services", "Sales" },
value: local!employeesDoc.department.departmenttype,
saveInto: local!employeesDoc.department.departmenttype,
required:true
),
/* For the Title Column*/
a!textField(

value: loggedInUser(),
readOnly: true,
saveInto: local!employeesDoc.department.createdby,

),
/* For the Phone Number Column*/
a!textField(

value: now(),
saveInto: local!employeesDoc.department.dateCreated
),


},

),

addRowlink: a!dynamicLink(
label: "Add Employee",

value: ri!docu,
saveInto: {
a!save(local!employeesDoc, append(local!employeesDoc, save!value))
}
),
rowHeader: 1
)
},
buttons: a!buttonLayout(
primaryButtons: a!buttonWidget(
label: "Submit",
submit: true
)
)
)
)

  Discussion posts and replies are publicly visible

Parents
  • 0
    Certified Lead Developer

    The problem here is you have configure the rows to have only one gridrowlayout. If you want multiple rows then you must iterate it through a list. Please refer the code snippet below.

    rows: a!forEach(
              items: local!employeesDoc,
              expression: a!gridRowLayout(
                contents: {
                  a!fileUploadField(),
                  /* For the Department Column*/
                  a!dropdownField(),
                  /* For the Phone Number Column*/
                  a!textField()
                }
              )
            ),
            addRowlink: a!dynamicLink(
              label: "Add Employee",
              saveInto: {
                a!save(
                  local!employeesDoc,
                  append(
                    local!employeesDoc,
                    'type!{urn:com:appian:types:AA}AA_Vehicaledata'(details: null)
                  )
                )
              }
            )

Reply
  • 0
    Certified Lead Developer

    The problem here is you have configure the rows to have only one gridrowlayout. If you want multiple rows then you must iterate it through a list. Please refer the code snippet below.

    rows: a!forEach(
              items: local!employeesDoc,
              expression: a!gridRowLayout(
                contents: {
                  a!fileUploadField(),
                  /* For the Department Column*/
                  a!dropdownField(),
                  /* For the Phone Number Column*/
                  a!textField()
                }
              )
            ),
            addRowlink: a!dynamicLink(
              label: "Add Employee",
              saveInto: {
                a!save(
                  local!employeesDoc,
                  append(
                    local!employeesDoc,
                    'type!{urn:com:appian:types:AA}AA_Vehicaledata'(details: null)
                  )
                )
              }
            )

Children
  • Thank  you for your reply . I already tried this way but i guess as I am using nested CDT so when i try to add other employee, its not working. Like i am unable to add the other row . 

    addRowlink: a!dynamicLink(
    label: "Add Employee",

    value: ri!docu,
    saveInto: {
    a!save(local!employeesDoc, append(local!employeesDoc, save!value))
    }

    )

    So i used rule input called that particular cdt , and then used it here . I am able to add a row but i am unable to get it  to store in the correct format i wanted. 

    The format i want to store is:

    Eg - Details: USER 1
    folder:{
    department:  CSE 
    createdby:loggedInUser(),
    dateCreated:now()
    }, 

    If i have multiple it should be stored in:

    Details: USER 1 , USER 2 , USER 3 
    folder:{
    department:CSE 
    createdby:loggedInUser(),
    dateCreated:now()
    },