Access CDT field Names ....

Lets say I have a CDT of 5 Fields that get populated. I'd like to create a grid that displays both the field name and the value. (A graphical representation of the CDT if you like).

i.e
TEST CDT

FieldA     Value1
FieldB     Value2
FieldC    Value3
FieldD    Value4
FieldE    Value5

I know that in the forEach loop I can access fv!item to get the value, but I'm not sure there's anything to get me the field names ??

 

  Discussion posts and replies are publicly visible

Parents
  • Hi Paul,

    I believe the below code example will return exactly what you're looking for.  Just match the type!MyCDT() with the type from your input and give your input some data

    = load(
      local!CDTFields: split(
        stripwith(
          tostring(
            'type!MyCDT'()
          ),
          "=[] "
        ),
        ","
      ),
      {
        a!paragraphField(
          value: local!CDTFields
        ),
        a!gridField(
          totalCount: length(
            ri!CDT
          ),
          columns: a!forEach(
            items: local!CDTFields,
            expression: a!gridTextColumn(
              label: fv!item,
              field: fv!item,
              data: index(
                ri!CDT,
                fv!item,
                null
              )
            )
          ),
          value: a!pagingInfo(
            startIndex: 1,
            batchSize: - 1
          )
        )
      }
    )

Reply
  • Hi Paul,

    I believe the below code example will return exactly what you're looking for.  Just match the type!MyCDT() with the type from your input and give your input some data

    = load(
      local!CDTFields: split(
        stripwith(
          tostring(
            'type!MyCDT'()
          ),
          "=[] "
        ),
        ","
      ),
      {
        a!paragraphField(
          value: local!CDTFields
        ),
        a!gridField(
          totalCount: length(
            ri!CDT
          ),
          columns: a!forEach(
            items: local!CDTFields,
            expression: a!gridTextColumn(
              label: fv!item,
              field: fv!item,
              data: index(
                ri!CDT,
                fv!item,
                null
              )
            )
          ),
          value: a!pagingInfo(
            startIndex: 1,
            batchSize: - 1
          )
        )
      }
    )

Children
No Data