how to inserted data in CDT from editable grid

Hii everyone

how to inserted data in CDT from editable grid?

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    You haven't provided much useful detail here - like, for instance, what you're trying to accomplish, or what (if anything) you've already tried.  Can you please elaborate?

  • I have created an editable grid with some fields(firstname ,lastname,address,email) I want the data to be entered through the grid in my table.


  • 0
    Certified Lead Developer

    Hi,

    Please refer to Appian documentation https://docs.appian.com/suite/help/22.1/recipe-add-edit-and-remove-data-in-an-inline-editable-grid.html

    It will provide details how you can configure editable grids and map to your CDTS etc

  • +1
    Certified Lead Developer
    in reply to jojog0002

    And in what way, specifically, is it not working?

  • I want to enter new data using grid then how to save that data in my table(CDT).

    editable grid code given below:

    a!localVariables(
    local!employees: rule!ED_GetEmployeeData(),
    a!formLayout(
    label: "Employee Details: Add,Update, or Remove Employee Data",
    contents: {
    a!gridLayout(
    totalCount: count(local!employees),
    headerCells: {
    a!gridLayoutHeaderCell(label: "First Name" ),
    a!gridLayoutHeaderCell(label: "Last Name" ),
    a!gridLayoutHeaderCell(label: "Email" ),
    a!gridLayoutHeaderCell(label: "ContactNumber" ),
    a!gridLayoutHeaderCell(label: "Designation" ),
    a!gridLayoutHeaderCell(label: "Department" ),
    a!gridLayoutHeaderCell(label: "Address" ),
    a!gridLayoutHeaderCell(label: "City" ),
    a!gridLayoutHeaderCell(label: "State" ),
    a!gridLayoutHeaderCell(label: "Country" ),
    a!gridLayoutHeaderCell(label: "Gender" ),
    a!gridLayoutHeaderCell(label: "Date of joining" ),
    /* For the "Remove" column */
    a!gridLayoutHeaderCell(label: "" )
    },
    /* Only needed when some columns need to be narrow */
    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 ),
    a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
    a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
    a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
    a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
    a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
    a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
    a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:3 ),
    a!gridLayoutColumnConfig(width: "DISTRIBUTE", weight:2 ),
    a!gridLayoutColumnConfig(width: "ICON")
    },
    /*
    * a!forEach() will take local!employee data and used that data to loop through an
    * expression that creates each row.
    *
    * When modifying the recipe to work with your data, you only need to change:
    * 1.) the number of fields in each row
    * 2.) the types of fields for each column (i.e. a!textField() for text data elements)
    * 3.) the fv!item elements. For example fv!item.firstName would change to fv!item.yourdata
    */
    rows: a!forEach(
    items: local!employees,
    expression: a!gridRowLayout(
    id: fv!index,
    contents: {
    /* For the First Name Column*/
    a!textField(
    /* Labels are not visible in grid cells but are necessary to meet accessibility requirements */
    label: "First Name " & fv!index,
    value: fv!item.FirstName,
    saveInto: fv!item.FirstName,
    required: true
    ),
    /* For the Last Name Column*/
    a!textField(
    label: "last name " & fv!index,
    value: fv!item.lastName,
    saveInto: fv!item.lastName,
    required:true
    ),
    /* For the Email Column*/
    a!textField(
    label: "Email " & fv!index,
    value: fv!item.Email,
    saveInto: fv!item.Email,
    required:true
    ),
    /* For the Contact Number Column*/
    a!textField(
    label: "ContactNumber " & fv!index,
    value: fv!item.ContactNumber,
    saveInto: fv!item.ContactNumber,
    required:true
    ),
    /* For the Designation Column*/
    a!dropdownField(
    label: "Designation " & fv!index,
    placeholder: "-- Select -- ",
    choiceLabels:{"Software Engineer","Support Engineer","Tester","Marking Specialist","Web Developer",".Net Developer","Graphic Designer"},
    choiceValues:{"Software Engineer","Support Engineer","Tester","Marking Specialist","Web Developer",".Net Developer","Graphic Designer"},
    value: fv!item.Designation,
    saveInto: fv!item.Designation,
    required:true
    ),
    /* For the Department Column*/
    a!dropdownField(
    label: "department " & fv!index,
    placeholder: "-- Select -- ",
    choiceLabels: { "Corporate", "Engineering", "Finance", "Human Resources", "Professional Services", "Sales" },
    choiceValues: { "Corporate", "Engineering", "Finance", "Human Resources", "Professional Services", "Sales" },
    value: fv!item.department,
    saveInto: fv!item.department,
    required:true
    ),
    /* For the Address Column*/
    a!textField(
    label: "Address " & fv!index,
    value: fv!item.Address,
    saveInto: fv!item.Address,
    required:true
    ),
    /* For the City Column*/
    a!dropdownField(
    label: "City " & fv!index,
    placeholder: "-- Select City-- ",
    choiceLabels: {"Delhi","Assam","Bihar","Arunachal Pradesh","Gujarat", "Uttar Pradesh"},
    choiceValues:{"Delhi","Assam","Bihar","Arunachal Pradesh","Gujarat", "Uttar Pradesh"},
    value: fv!item.City,
    saveInto: fv!item.City,
    required:true
    ),
    /* For the State Column*/
    a!dropdownField(
    label: "State " & fv!index,
    placeholder: "-- Select State-- ",
    choiceLabels: {"Delhi","New Delhi","Bettiah","Jamalpur","Ahmadabad","Agra","Aligarh"},
    choiceValues: {"Delhi","New Delhi","Bettiah","Jamalpur","Ahmadabad","Agra","Aligarh"},
    value: fv!item.State,
    saveInto: fv!item.State,
    required:true
    ),
    /* For the Country Column*/
    a!dropdownField(
    label: "Country " & fv!index,
    placeholder: "-- Select Country-- ",
    choiceLabels:{"India","Russia","USA","Germany","Austriala"},
    choiceValues:{"India","Russia","USA","Germany","Austriala"},
    value: fv!item.Country,
    saveInto: fv!item.Country,
    required:true
    ),
    /* For the Gender Column*/
    a!textField(
    label: "Gender" & fv!index,

    value: fv!item.Gender ,
    saveInto: fv!item.Gender
    ),
    /* For the Hire Date Column*/
    a!dateField(
    label: "Date of Joining " & fv!index,
    value: fv!item.Hire_Date,
    saveInto: fv!item.Hire_Date,
    required:true,
    align: "RIGHT"
    ),
    /* For the Removal Column*/
    a!richTextDisplayField(
    value: a!richTextIcon(
    icon: "trash-o",
    altText: "delete " & fv!index,
    caption: "Remove " & fv!item.firstName & " " & fv!item.lastName,
    link: a!dynamicLink(
    value: fv!index,
    saveInto: {
    a!save(local!employees, remove(local!employees, save!value))
    }
    ),
    linkStyle: "STANDALONE",
    color: "NEGATIVE"
    )
    )
    }
    )
    ),
    addRowlink: a!dynamicLink(
    label: "Add Employee",
    /*
    * For your use case, set the value to a blank instance of your CDT using
    * the type constructor, e.g. type!Employee(). Only specify the field
    * if you want to give it a default value e.g. startDate: today()+1.
    */
    value: {
    startDate: today() + 1
    },
    saveInto: {
    a!save(local!employees, append(local!employees, save!value))
    }
    ),
    rowHeader: 1
    )
    },
    buttons: a!buttonLayout(
    primaryButtons: a!buttonWidget(
    label: "Submit",
    submit: true
    )
    )
    )
    )

  • if i enter a new data then how to save that data in my table?

  • 0
    Certified Lead Developer
    in reply to jojog0002

    In short, the interface fields would be configured to save into your data elements (in a Rule Input typically); then when the form is submitted, the data is passed back into the Process, where you will need to have configured a Write to Data Store node pointing at the Data Store for the proper table, and taking the data (via its PV) in as an input.

    I'd highly suggest you complete the online learning resources if you're not familar with these steps, as this is a standard use case for Appian applications and is also just slightly too much for us to walk you through, here, from scratch.

    If on the other hand you're just missing a piece then we're happy to help, but in general it's best to start off by telling us as much information as you can so we know where to start.

  • 0
    Certified Senior Developer
    in reply to jojog0002

    Hi Jo,

    a!textField(
    label: "Text",
    labelPosition: "ABOVE",

    value: ri!firstname
    saveInto: {ri!firstname},
    refreshAfter: "UNFOCUS",
    validations: {}
    )

    When you save the first name in saveInto parameter then that will save in the rule input(CDT). If you are using multiple rows with multiple value then you have to enable an array check box in the rule input of the particular CDT.

  • 0
    Certified Lead Developer
    in reply to jojog0002
    a!buttonWidget(
    label: "Submit",
    submit: true
    )

    saveInto: {
      a!save(ri!employeeList, local!employees)
    }