How to get hold of the data in the nested array?

I am trying to build a report in Tempo but I am getting stuck on how to get hold of the data in the nested array. Here is an example of what I am working with along with the report I have built so far. Should I restructure my CDT or is it possible to get the results I want?

CDT defined Data Store Entity
Items--value1
value2
           array--a1 (Milestone Name - start, middle, end)
           a2 (Boolean status - true, null, null)
                     a3 (Datetime Stamp - datetime, datetime, datetime)
                              
Display in SAIL report as:
value1 - value2 - a1 - a2 - a3

load(
local!arrayPaging: a!pagingInfo(
startIndex: 1,
batchSize: 20
),
with(
local!arrayData:
todatasubset(
rule!FetchArray(
ri!matchingid
),
local!arrayPaging)
,
a!gridField(
label: "Display in SAIL report",
totalCount: local!arrayData.totalcount,
columns: {
a!gridTextCol...

OriginalPostID-168593

OriginalPostID-168593

  Discussion posts and replies are publicly visible

  • ...umn(
    label: "value1",
    field: "value1",
    data: index(local!arrayData.data, "value1", null)
    ),
    a!gridTextColumn(
    label: "value2",
    field: "value2",
    data: index(local!arrayData.data, "value2", null)
    ),
    a!gridTextColumn(
    label: "a1",
    field: "a1",
    >> data: index(local!arrayData.data, "a1", null)
    )

    },
    value: local!arrayPaging
    )
    )
    )

    It seems to me I should be able to use .notation to access the array values a1 to a3 using a fixed index but this isn't working for me. Is there an alternative?
    Thanks, James
  • Hello could you please attach you CDT definition? Thanks
  • @james.franklin The way how I generally do it is by creating a formatted rule:

    getConcatenatedListForMultipleItems
    1. list (Any Type)
    2. column (Text)

    Definition:
    if(
    \trule!APN_isEmpty(index(ri!list,ri!column,null)),
    \tnull,
    \tjoinarray(index(ri!list,ri!column,null),"; ")
    )

    And you could invoke the above formatted rule as follows:
    a!gridTextColumn(
    label: "a1",
    field: "a1",
    data: apply(rule!getConcatenatedListForMultipleItems(_,"a1"),local!datasubset.data)
    ),
    a!gridTextColumn(
    label: "a2",
    field: "a2",
    data: apply(rule!getConcatenatedListForMultipleItems(_,"a2"),local!datasubset.data)
    )

    But again I guess making a reusable rule may not work all the times, because each column will have its own formatting style, such as a boolean might need to be represented as Yes/ No, a date time might need to be represented as DD MMM YYYY HH:MM etc. Not sure how far this is correct but let's see if any other practitioner comes up with better suggestions.

    Just to let you know why we need to do above is, the data provided to a!gridTextColumn is flattened automatically as far as my knowledge is considered and some times it could be also a problem when it is accessing an array of arrays. So that's why we need to build a formatted rule which outputs the data exactly that matches the number of rows in a page.
  • XSD file attached for reference. It is defining a data store currently.

    HRCandidate.xsd

  • @sikhivahans, thank you for your reply, I can see how this could help however because I have paged the initial array of items Appian considers the array values as a nested multiple which I believe breaks best practice. Also because each item has 3 elements to the array the paging breaks. I could try paging the array element in addition to the items then figure out some way to reference them. It seems the overhead for this could be excessive for what I am trying to achieve. I will keep experimenting for the time being. Thanks, James
  • Well I have resolved the problem. There are probably more efficient methods for those willing to try. However the journey was fun and has concluded with me deciding to drop the data that has cause me so much trouble in favor of a simpler approach. For reference here was my solution: The analytic report which inspired the SAIL report in the first place turned out to be the data source.

    load(
    local!pagingInfo: a!pagingInfo(
    startIndex: 1,
    batchSize: 20
    /* Change the batch size to -1 if this interface will be used when offline */
    ),
    with(
    local!candidateData: a!queryProcessAnalytics(
    report: cons!CandidateQPA,
    contextProcessModels: cons!CandidatePMcontext,
    query: a!query(
    filter: a!queryFilter(
    field: "c15",
    operator: "=",
    value: ri!roleppidpk
    ),
    pagingInfo: a!pagingInfo(startIndex: 1, batchSize: 20)
    )
    ),
    a!gridField(
    label: "Candidates",
    totalCount: local!candidateData.totalcount,
    columns: {
    a!gridTextColumn(label: "Candidate", field: "c3", data: index(local!candidateData.data, "c3", {})),
    a!gridTextColumn(label: "Received", field: "c3", data: {apply(text(_,"dd/mm/yyyy hh:mm"),index(local!candidateData.data, "c4", {}))}),
    a!gridImageColumn(label: "Review", field: "c6", data: {apply(rule!CandidateProgressIcons,index(local!candidateData.data, "c6", {}))}),
    a!gridImageColumn(label: "Test", field: "c7", data: {apply(rule!CandidateProgressIcons,index(local!candidateData.data, "c7", {}))}),
    a!gridImageColumn(label: "Interview 1", field: "c8", data: {apply(rule!CandidateProgressIcons,index(local!candidateData.data, "c8", {}))}),
    a!gridImageColumn(label: "Interview 2", field: "c9", data: {apply(rule!CandidateProgressIcons,index(local!candidateData.data, "c9", {}))}),
    a!gridTextColumn(label: "Status", field: "c12", data: index(local!candidateData.data, "c12", {}))
    },
    value: local!pagingInfo
    )
    )
    )
  • Nice work James! Appian best practices tell us that nesting arrays of CDTs in CDTs is generally not recommended. However you can establish complex data relationships by creating id fields relating to each CDT's primary key. Good luck with development!