How do you go about loading data from a CDT to display in an interface

Hi all,

Absolute newbie in appian here.  I have been tasked with developing a form that allows me to choose cases and tasks and transfer ownership of them to another user.

I have created a simple process model, with  just  a start and end node, and set up the process start form for the process model, to an interface that I hope will display the available tasks and cases, and allow me to select them, and then to choose a user to whom I want to transfer ownership.

I don't know if my approach is wrong, and consequently if there's a better way to do this, or if this approach is as good as any.

Part 1 of the task is to get a form up that allows me to identify the tasks and cases I want to transfer and to identify the user to whom I want to transfer them.  There's an existing process model that I can probably call once I have identified tasks, cases and the user to whom ownership should be transferred - so first is to get the data into the interface so I can choose from the list.

I have created two local variables in my interface by putting code at the start of my interface that look like this:

load(
local!dbTasks: a!queryEntity(
entity: cons!iMY_TASKS_DS,
query: a!query(
pagingInfo: a!pagingInfo(
startIndex: 1,
batchSize: 10
)
)
),
local!dbCases: a!queryEntity(
entity: cons!iMY_CASE_DETAILS_DS,
query: a!query(
pagingInfo: a!pagingInfo(
startIndex: 1,
batchSize: 10
)
)
),

I then have a sectionLayout that looks like this:

a!sectionLayout(
label: "Section",
contents: {
a!pickerFieldUsers(
label: "User Picker",
labelPosition: "ABOVE",
saveInto: {},
validations: {}
),
a!gridField
(
label: "Tasks to select from",
totalCount: if(
rule!APN_isEmpty(
index(local!dbTasks,"data","")
),
0,
index(
local!dbTasks,
"data.totalCount",
0
)
),
columns: {
a!gridTextColumn(
label: "Task ID",
field: "taskId",
data: index(
local!dbTasks,
"taskId",
{}
)
),
a!gridTextColumn(
label: "Task Description",
field: "taskDescription",
data: index(
local!dbTasks,
"taskDescription",
{}
)
)
},
value: local!taskGridSelection,
saveinto: local!dbTasks
),
a!gridField
(
label: "Cases to select from",
totalCount: if(
rule!APN_isEmpty(
index(local!dbCases,"data","")
),
0,
index(
local!dbCases,
"data.totalCount",
0
)
),
columns: {
a!gridTextColumn(
label: "Case Number",
field: "caseNumber",
data: index(
local!dbTasks,
"caseNumber",
{}
)
),
a!gridTextColumn(
label: "Case Description",
field: "caseDescription",
data: index(
local!dbCases,
"caseDescription",
{}
)
)
},
value: local!caseGridSelection,
saveinto: local!dbCases
)

}
)

However, when I run this form, no data is loaded into the two grids.  What do I need to do to get the data into the grids?

thanks heaps,

David.

  Discussion posts and replies are publicly visible

  • 0
    Certified Lead Developer

    Hi David!

    The data is not coming in the grid because you are using the code as  index(local!dbTasks,"caseNumber",{}). Here you need to change the syntax as -

    index(
    local!dbTasks.data,
    "caseNumber",
    {}
    )
    . Note the 'data' part contains the data inside a datasubset.

  • 0
    Certified Lead Developer

    Below is a list of recommendations/changes you need to incorporate so that code can function properly.

    1. Create two different local variables for paging info, to be used by task and cases grid exclusively. 

    2. Query the database inside a with(). In other words, task and cases datasubset should be populated inside a with() block so that they can be reevaluated.

    load(
    local!taskPaging:a!pagingInfo(1,10),
    local!casePaging:a!pagingInfo(1,10),
    with(
    /*taskPaging for Task data subset*/
    local!taskDatasubset:a!queryEntity(entity:{},pagingInfo:local!taskPaging),
    /*CasePaging for Case Data subset*/
    local!caseDatasubset:a!queryEntity(entity:{},pagingInfo:local!casePaging),
    /*Sample Grid Code*/
    a!gridField(
    label:"Tasks",
    columns:{
    a!gridTextColumns(
    data:index(local!taskDatasubset.data,"taskName",{}))},
    saveInto:local!taskPaging,
    value:local!taskPaging)
    ))

    3.The syntax for total count is incorrect, It should be like

     

    if(
    rule!APN_isEmpty(
    index(local!dbTasks,"data","")
    ),
    0,
    index(
    local!dbTasks,
    "totalCount",
    0
    ))

    totalCount is an attribute of datasubset so "data.totalCount" is an incorrect expression. Though local!dbTasks.totalCount is correct.

  • thanks heaps for this - I'm looking at your suggestions at the moment.  will let you know when I've got something that compiles after the changes... :-)

  • load(
      local!taskGridSelection: a!gridSelection(
        selected: {},
        pagingInfo: a!pagingInfo(
          startIndex: 1,
          batchSize: 10
        )
      ),
      local!caseGridSelection: a!gridSelection(
        selected: {},
        pagingInfo: a!pagingInfo(
          startIndex: 1,
          batchSize: 10
        )
      ),
      with(
        local!dbTasks: a!queryEntity(
          entity: cons!iMY_TASKS_DS,
          query: a!query(
            pagingInfo: local!taskGridSelection.pagingInfo
          ),
          fetchTotalCount: true
        ),
        local!dbCases: a!queryEntity(
          entity: cons!iMY_CASE_DETAILS_DS,
          query: a!query(
            pagingInfo: local!caseGridSelection.pagingInfo
          )
        ),
        a!sectionLayout(
          label: "Section",
          contents: {
            a!gridField(
              label: "",
              totalCount: local!dbTasks.totalCount,
              columns: {
                a!gridTextColumn(
                  label: "Task ID",
                  field: "taskId",
                  data: index(
                    local!dbTasks.data,
                    "taskId",
                    {}
                  )
                ),
                a!gridTextColumn(
                  label: "Task Description",
                  field: "taskDescription",
                  data: index(
                    local!dbTasks.data,
                    "taskDescription",
                    {}
                  )
                )
              },
              identifiers: local!dbTasks.identifiers,
              value: local!taskGridSelection,
              saveInto: {
                local!taskGridSelection
              },
              rowHeader: 1,
              selection: true,
              shadeAlternateRows: false
            ),
            a!gridField(
              label: "",
              totalCount: local!dbCases.totalCount,
              columns: {
                a!gridTextColumn(
                  label: "Case Number",
                  field: "caseNumber",
                  data: index(
                    local!dbCases.data,
                    "caseNumber",
                    {}
                  )
                ),
                a!gridTextColumn(
                  label: "Case Description",
                  field: "caseDescription",
                  data: index(
                    local!dbCases.data,
                    "caseDescription",
                    {}
                  )
                )
              },
              identifiers: local!dbCases.identifiers,
              value: local!caseGridSelection,
              saveInto: {
                local!caseGridSelection
              },
              rowHeader: 1,
              selection: true
            )
          }
        )
      )
    )