Grid Tutorial

hi! i'am at the 8. populate display section Step and i have this problem.

the sail interface is this:

{
a!columnsLayout(
columns: {
a!columnLayout(
contents: {
a!localVariables(
local!selection,
local!selectedEmployees,
{
a!gridField(
label: "Read-only Grid",
labelPosition: "ABOVE",
data: a!queryEntity(
entity: cons!EMPLOYEE_ENTITY,
query: a!query(
selection: a!querySelection(
columns: {
a!queryColumn(
field: "id"
),
a!queryColumn(
field: "firstName"
),
a!queryColumn(
field: "lastName"
),
a!queryColumn(
field: "department"
),
a!queryColumn(
field: "startDate"
)
}
),
pagingInfo: fv!pagingInfo
),
fetchTotalCount: true
),
columns: {
a!gridColumn(
label: "First Name",
sortField: "firstName",
value: fv!row.firstName
),
a!gridColumn(
label: "Last Name",
sortField: "lastName",
value: fv!row.lastName
),
a!gridColumn(
label: "Department",
sortField: "department",
value: a!richTextDisplayField(
value: {
a!richTextItem(
text: {fv!row.department},
color: if(fv!row.department="Sales", "SECONDARY", null),
style: {
"EMPHASIS"
}
)
}
)
),
a!gridColumn(
label: "Start Date",
sortField: "startDate",
value: fv!row.startDate,
align: "END"
)
},
pagesize: 5,
initialsorts: {
a!sortInfo(
field: "lastName",
ascending: true
)
},
selectable: true,
selectionvalue: local!selection,
selectionsaveinto: {
local!selection,
/* This save adds the full rows of data for items selected in the most recent user interaction to local!selectedEmployees. */
a!save(local!selectedEmployees, append(local!selectedEmployees, fv!selectedRows)),
/* This save removes the full rows of data for items deselected in the most recent user interaction to local!selectedEmployees. */
a!save(local!selectedEmployees, difference(local!selectedEmployees, fv!deselectedRows))
},
disablerowselectionwhen: fv!row.department="Sales",
validations: {}
)
}
)
},
width: "WIDE"
),
a!columnLayout(
contents: {
a!richTextDisplayField(
label: "Selected Employees",
labelPosition: "ABOVE",
value: a!forEach(
items: local!selectedEmployees,
expression: {
a!richTextIcon(
icon: "user-circle"
),
" "&fv!item.firstName &" "&fv!item.lastName&char(10)
}
)
)
}
)
}
)
}

  Discussion posts and replies are publicly visible

  • Hello,

    You are missing the local variables.

    Something like that, with the closing of a!localVariables should fix the issue.

    	
    
    a!localVariables(
      /*  
      * local!employess is provided in this recipe as a way to start with hard-coded
      * data. However, this data is identical to the data created from the entity-backed
      * tutorial. Replace the hard-coded data with a query to the employee data store
      * entity and all of the employee records from the tutorial will appear.
      *
      * To replace this data with your own, replace (ctrl+H or cmd+H) all references to
      * local!employees with your data source, either via rule input or local variable.
      */
      local!employees: {
        { id: 1, firstName: "John" , lastName: "Smith" , department: "Engineering" , title: "Director" , phoneNumber: "555-123-4567" , startDate: today()-360 },
        { id: 2, firstName: "Michael" , lastName: "Johnson" , department: "Finance" , title: "Analyst" , phoneNumber: "555-987-6543" , startDate: today()-360 },
        { id: 3, firstName: "Mary", lastName: "Reed" , department: "Engineering" , title: "Software Engineer" , phoneNumber: "555-456-0123" , startDate: today()-240 },
      },

    From here https://docs.appian.com/suite/help/20.1/SAIL_Recipes.html you can find examples with the definitions.

    Copy and paste here

    a!localVariables(
      /*  
      * local!employess is provided in this recipe as a way to start with hard-coded
      * data. However, this data is identical to the data created from the entity-backed
      * tutorial. Replace the hard-coded data with a query to the employee data store
      * entity and all of the employee records from the tutorial will appear.
      *
      * To replace this data with your own, replace (ctrl+H or cmd+H) all references to
      * local!employees with your data source, either via rule input or local variable.
      */
      local!employees: {
        { id: 1, firstName: "John" , lastName: "Smith" , department: "Engineering" , title: "Director" , phoneNumber: "555-123-4567" , startDate: today()-360 },
        { id: 2, firstName: "Michael" , lastName: "Johnson" , department: "Finance" , title: "Analyst" , phoneNumber: "555-987-6543" , startDate: today()-360 },
        { id: 3, firstName: "Mary", lastName: "Reed" , department: "Engineering" , title: "Software Engineer" , phoneNumber: "555-456-0123" , startDate: today()-240 },
      },
      a!formLayout(
        label: "Example: 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: "Department" ),
              a!gridLayoutHeaderCell(label: "Title" ),
              a!gridLayoutHeaderCell(label: "Phone Number" ),
              a!gridLayoutHeaderCell(label: "Start Date", align: "RIGHT" ),
              /* 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: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(
                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 Department Column*/
                  a!dropdownField(
                    label: "department " & fv!index,
                    placeholderLabel: "-- 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 Title Column*/
                  a!textField(
                    label: "title " & fv!index,
                    value: fv!item.title,
                    saveInto: fv!item.title,
                    required:true
                  ),
                  /* For the Phone Number Column*/
                  a!textField(
                    label: "phone number " & fv!index,
                    placeholder:"555-456-7890",
                    value: fv!item.phoneNumber,
                    saveInto: fv!item.phoneNumber
                  ),
                  /* For the Start Date Column*/
                  a!dateField(
                    label: "start date " & fv!index,
                    value: fv!item.startDate,
                    saveInto: fv!item.startDate,
                    required:true,
                    align: "RIGHT"
                  ),
                  /* For the Removal Column*/
                  a!richTextDisplayField(
                    value: a!richTextIcon(
                      icon: "close",
                      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"
                    )
                  )
                },
                id: fv!index
              )
            ),
            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
          )
        )
      )
    )

  • thanks but i don't understand, why copy and paste if isn't what i need?

    i'm doing the grid tutorial. i follow all steps but i have this issue.

  • 0
    A Score Level 1
    in reply to leo_scr

    I have no idea what the tutorials says, but probably it is assuming the data comes from somewhere.

    In this case, you are giving data to the variables you are trying to see to which you are making reference to.

    This, defines the data you will see in the grid, but typically you will not have it hardcoded.

      local!employees: {
        { id: 1, firstName: "John" , lastName: "Smith" , department: "Engineering" , title: "Director" , phoneNumber: "555-123-4567" , startDate: today()-360 },
        { id: 2, firstName: "Michael" , lastName: "Johnson" , department: "Finance" , title: "Analyst" , phoneNumber: "555-987-6543" , startDate: today()-360 },
        { id: 3, firstName: "Mary", lastName: "Reed" , department: "Engineering" , title: "Software Engineer" , phoneNumber: "555-456-0123" , startDate: today()-240 },
      },

  • ok thanks, i write manualy the empoloyees and the richtext it's ok. the problem is that the local!selectedEmployees isn't populated when i select an row un the grid.