Need help on how to display all the rows of a column

Hi,

I have a DB table which has two columns,that is, ID and VALUE columns

And there are 5 rows.

My requirement is how to display (Value Columns) different values in five rich texts as their names.

Thanks

Faisal

  Discussion posts and replies are publicly visible

  • I am using the below codes..It is ok?

    a!localVariables(
    local!empData:rule!FF_EMP_QE_EmpType(typeId: null),
    {a!columnsLayout(
    columns: {
    a!columnLayout(
    contents: {
    a!cardLayout(
    contents: a!richTextDisplayField(
    value: {
    a!richTextIcon(
    icon: "money",
    color: "ACCENT",
    size: "LARGE"
    ),
    char(10),
    a!richTextItem(
    text: a!forEach(items: local!empData,
    expression: fv!item.emptype)[1],
    /*text: local!empData[1].emptype*/

    size: "LARGE")

    },
    align: "CENTER"
    ),
    /* Setting this variable would be used to navigate to a category of answers */
    /*link: a!dynamicLink(saveInto: a!save(local!category, "Finance")),*/
    height: "AUTO",
    marginBelow: "STANDARD"
    )})})})

  • 0
    Certified Lead Developer
    in reply to faisalf0003
    a!forEach(items: local!empData,
    expression: fv!item.emptype)[1],

    I'm not really sure what you're trying to do here, but this specific piece of code will manually index the first ([1]) result of the array generated by the a!forEach() loop, basically making it meaningless.  I think it might be closer to your desired end result just by removing the "[1]".

    Also: for code like this (or any SAIL or expression code really) I strongly suggest inserting your code into a Code Box ("Insert" --> "Insert Code" in the in-editor menu here), as this retains formatting like indentation and uses an easier font for reading code.  When asking others to review your code it's a good idea to make it as easy to read as you can.

  • 0
    Certified Lead Developer

    I think this can be very, very easy.

    index() and property() both do the same thing, but index() also does numerical indexes.

    property(local!cdt, "value", {}) returns the "value" column of a single local!cdt.  It returns an array of "value"s if local!cdt is an array.  Same for index().

    local!cdt: {{id: 1, value: "A"}, {id:2, value: "B"}, {id:3, value: "C"}},
    index(local!cdt, "value", {})

    Should return {"A", "B", "C"}  No looping required; property() and index() should both automatically loop for you.

    Once you have 5 text strings, just a!forEach( items: local!textStrings, expression: richText(....text: fv!item, ....))

    If you need to combine elements, gather your CDT in a local like you're doing now, then a!forEach( items: local!CDTData, expression: richText( . . . text: property(fv!item, "name", {}) & property(fv!item, "someOtherField"), ....))

  • 0
    Certified Lead Developer
    in reply to Dave Lewis
    but index() also does numerical indexes.

    technically both functions do, but as strongly as i harp about using only property() to get properties, i say the same about only using index() to get indexes.