Cannot display the rest of the fields in a grid

Hi everyone, 

I currently have a grid that only displays one out of six columns. I recently added the last five out of six column fields, but for some reason, none of the new fields are displaying. Does anyone have an idea of what I'm doing wrong? 

 

Unfortunately, I was passed down this code from someone else and am a newbie to Appian, so the code is pretty large. If anyone can direct me to what the specific piece of code entails that I should show you all to help debug, that'd be great too. 

  Discussion posts and replies are publicly visible

Parents
  • 1) I will suggest to take a look at a simpler version of the component (see the references I added at the bottom)

    2) Can you confirm somethings:
    * I am guessing the first column is showing proper information?
    * which component are you using, for me it sounds like gridField?

    2.1) Since the columns are shown and the data information is not shown,
    I am guessing this is the "gridField" then it might be as simple as the value/data you are passing but it always depends on the component you are using. in this case try this:
    2.1.1) The data field/parameter should be a list
    a!gridTextColumn(
    label: "Field",
    field: "field",
    data: index(ri!dataSubset.data,"field",{} )
    )
    2.1.2) if you are using a rule this maybe is not returning a list it self
    a!gridTextColumn(
    label: "Field",
    field: "field",
    data: a!forEach(
    items: index(ri!dataSubset.data,"field",{} ),
    expression: rule!someRule(param: fv!item)
    )
    )


    2.2) if it were the component "gridLayout" try this:
    * first to show the same information from the first column ( the one you already have)
    * check if you don't have a showWhen to false or if the data is not null

    4) If previous things are correct then make sure the data is not null.


    5) As a reference you can take a look at this links
    Paging Grid - SAIL Function: a!gridField()
    * docs.appian.com/.../Paging_Grid_Component.html
    Editable Grid - SAIL Function: a!gridLayout()
    * docs.appian.com/.../Editable_Grid_Component.html


    If nothing of this works please let us know
  • Hi, to answer your first question. The first column is displaying properly. I am using gridField.
    Here is a piece of my grid field code:

    a!gridField(
    label: cons!TEXT_SELECT_A_STORE_LABEL,
    totalCount: ri!storeData.totalCount,
    columns: {
    a!gridTextColumn(
    label: cons!TEXT_NAME_LABEL,
    field: "Name",
    data: index(
    ri!storeData.data,
    "Name",
    {}
    )
    ),
    a!gridTextColumn(
    label: cons!TEXT_STORE_ID_LABEL,
    field: "storeID",
    data: index(
    ri!storeData.data,
    "storeID",
    {}
    )
    ),

    the Name label and data displays. The ID does not.

  • Also,

    I noticed you had a foreach in the 2.1.2. There is also a main form that is calling this grid.

    Here is some code from that form.
    local!data: if(
    rule!AF_RULE_General_isBlank(
    local!unSelectableEntityData
    ),
    local!stores,
    if(
    local!unSelectableEntityData.totalCount = 0,
    local!stores,
    remove(
    local!stores,
    wherecontains(
    touniformstring(
    {local!unSelectableEntityData.data.Name, local!unSelectableEntityData.data.storeID}
    ),
    local!stores
    )
    )
    )
    ),

    local!filterData: if(
    rule!AF_RULE_General_isBlank(
    local!search
    ),
    {},
    index(
    local!data,
    where(
    like(
    lower(local!data),
    "*" & lower(local!search) & "*"
    )
    )
    )
    ),

    local!sampleData: if(
    rule!AF_RULE_General_isBlank(
    local!search
    ),
    {
    {}
    },

    {
    a!forEach(
    items: local!filterData,
    expression: 'type!{urn:com:appian:types:store}store_Entity'(
    Name: local!filterData[fv!index]
    )
    )
    }
    ),

    local!entityData: todatasubset(
    local!sampleData,
    local!gridSelection.pagingInfo
    ),
    local!selectedStoresData: todatasubset(
    local!selectedStores,
    local!gridSelection2.pagingInfo
    ),
  • 1) Can you try this? ans see what you get?
    a!gridTextColumn(
    label: cons!NMLS_TEXT_STORE_ID_LABEL,
    field: "storeID",
    data: index(
    ri!storeData.data,
    "storeID",
    "*We have not DATA *"
    )
    ),

    2) to make sure you get the information in the datasubset add a "paragraphField "
    ...
    a!paragraphField(value:ri!storeData.data),
    a!gridField(
    label: cons!NMLS_TEXT_SELECT_A_STORE_LABEL,
    ...

    This will tell you lot of information
  • As soon as I typed the "*We have not DATA *" and attempted to test, I received this error:

    Could not display interface. Please check definition and inputs.
    Interface Definition: Expression evaluation error in rule 'grid_user_selectstores' at function a!gridField: A grid component [label=“Please select a store. ”] has an invalid value for “totalCount”. “totalCount” must not be null or less than the number of items in any of the “data” arrays, but “totalCount” was 0 and the largest column data array had 1 items.

  • hey this part you are just creating object with 1 field, the Name, then the other fields won't have values


    a!forEach(
    items: local!filterData,
    expression: 'type!{urn:com:appian:types:store}store_Entity'(
    Name: local!filterData[fv!index]
    )
    )
  • Yes sorry, I added another comment, let me check this
  • Actually, as I said this should be an array, thats why it prompted an error. Sorry about it return it to {} try the 2) option you will see the information ( please delte it when you finish)

    In the previous comment I noticed this.
    hey this part you are just creating object with 1 field, the Name, then the other fields won't have values
    a!forEach(
    items: local!filterData,
    expression: 'type!{urn:com:appian:types:store}store_Entity'(
    Name: local!filterData[fv!index],
    storeID: local!filterData[fv!index]
    )
    )

    It seems like the problem is on the information the grid is receiving.
  • Ok. So I'm going to try and explain what I just did.

    Upon looking at the forEach again, I realized that it is calling the CDT Store_Entity. That CDT did not have the storeID name nor type which was probably part of the issue. So what I did was add a field from that CDT (phone number) to the a!foreach. It now says

    a!forEach(
    items: local!filterData,
    expression: 'type!{urn:com:appian:types:store}store_Entity'(
    name: local!filterData[fv!index],
    storeNumber: local!filterData[fv!index]
    )
    )
    This allowed for the second column to populate. However, the phone number is not in the second column, the name is. So now I have two columns with the same store name even though the second column says Store Number.
  • 0
    Certified Lead Developer
    in reply to ck0220

    The only reason I can think of why storeID might not be displaying is that your data set (ri!storeData.data) doesn't contain a property with the exact name "storeID".  You probably need to check whether it's something different.

    By way of testing, you can display the exact value of the datasubset you're working with in a test paragraph field that you can then remove later.

    a!paragraphField(
      label: "DEBUG",
      value: ri!storeData,
      readOnly: true()
    )

  • Hi Mike,

    Any time I attempt to add the paragraph field before the grid field, I receive the error:

    Could not display interface. Please check definition and inputs.
    Interface Definition: Expression evaluation error while parsing rule 'grid_user_selectentities': Missing right parenthesis in expression, found COMMA

    But there is no right parenthesis missing
  • 0
    Certified Lead Developer
    in reply to ck0220

    We would need more context as to your overall form in order to know why you're getting that error (though i'd guess it's just syntax).

    As a side note, I strongly encourage you to use the "Insert Code" tool in the Insert menu, to avoid making your posts impossible to read when pasting large chunks of code, and to retain formatting (which makes code 10x easier to read).

Reply
  • 0
    Certified Lead Developer
    in reply to ck0220

    We would need more context as to your overall form in order to know why you're getting that error (though i'd guess it's just syntax).

    As a side note, I strongly encourage you to use the "Insert Code" tool in the Insert menu, to avoid making your posts impossible to read when pasting large chunks of code, and to retain formatting (which makes code 10x easier to read).

Children
  • Update:

    Part of the reason the information was not displaying was because the CDT was using the incorrect fields. The CDT now uses the correct fields and all of the columns in the grid display information!

    However, now all of the information is the exact same as the first column.

    This is the new code:
    a!forEach(
    items: local!filterData,
    expression: 'type!{urn:com:appian:types:store}store_Entity'(
    name: local!filterData[fv!index],storeID:  local!filterData[fv!index],
    storeNumber: local!filterData[fv!index],
    storeManager: local!filterData[fv!index],
    storeCity: local!filterData[fv!index],
    storeState: local!filterData[fv!index]
    )
    )

    What would be the reasoning for the duplication of information?

  • 0
    Certified Lead Developer
    in reply to ck0220
    In the code you've pasted, you're setting every property to the same value (the value of "local!filterData[fv!index]"). I'm not clear why you're even doing this type! casting - you should just be able to display data in the grid straight from the data you're receiving in your rule input.
  • Not sure if you read earlier, but this was code passed down to me. I'm not sure exactly why the type! casting is happening either to be honest.

    Here's the piece of code containing filterData if that helps.
    local!filterData: if(
    rule!AF_RULE_General_isBlank(
    local!search
    ),
    {},
    index(
    local!data,
    where(
    like(
    lower(local!data),
    "*" & lower(local!search) & "*"
    )
    )
    )
    ),
  • you are doing this look specially to this comments"/* << Repeating data*/"

    This is the new code:
    a!forEach(
    items: local!filterData,
    expression: 'type!{urn:com:appian:types:store}store_Entity'(
    name: local!filterData[fv!index],
    storeID: local!filterData[fv!index], /* << Repeating data*/
    storeNumber: local!filterData[fv!index], /* << Repeating data*/
    storeManager: local!filterData[fv!index],/* << Repeating data*/
    storeCity: local!filterData[fv!index],/* << Repeating data*/
    storeState: local!filterData[fv!index]/* << Repeating data*/
    )
    )

    Which is assigning the same values to all the columns, that was exactly the test i was trying to make. so the gird it self its right, the data you are passing is the problem. But for this new we need more context on the information where you are getting this values "local!filterData"

    Because as i see it self "filterData" is an array which you are assigning the same values all the collumns in the grid.
    As Mike commented you can get the information directly from the rule

    Jose
  • I have a hard coded array called "stores" with 10 different store names, id, phone number, etc.
    local!entities: {
    {"Store One","s1", "BON", "Des Moines", "IA"},
    {"Store Two", "s2", "BTW", "Boise", "ID"},
    {"Store Three", "s3", "BTH", "Charlotte", "NC"},
    {"Store Four", "s4", "BFR", "New York", "NY"},
    {"Store Five", "s5", "BFV", "Houston", "TX"},
    {"Store Six", "s6", "BSX", "Seattle", "WA"},
    {"Store Seven", "s7", "BSVN", "Jersey City", "NJ"},
    {"Store Eight", "s8", "BET", "El Paso", "TX"},
    {"Store Nine", "s9", "BNI", "Jersey City", "NJ"},
    {"Store Ten", "s10", "BTN", "Fort Worth", "TX"}
    },

    I changed the filterData [fv!index] to this.

    a!forEach(
    items: local!filterData,
    expression: 'type!{urn:com:appian:types:stores}stores_Entity'(
    Name: local!stores[fv!index],
    storeid: local!stores [fv!index],
    storeSymbol: local!stores[fv!index],
    storeCity: local!stores[fv!index],
    storeState: local!stores[fv!index]
    )
    )

    I now have success in displaying different information, but it is not displaying in the correct fashion.
  • i am trying to display a picture of the grid, but it will not let me
  • Boise Boise Boise Boise Boise
    BON BON BON BON BON
    BTW BTW BTW BTW BTW
    Des Moines Des Moines Des Moines Des Moines Des Moines
    IA IA IA IA IA
    ID ID ID ID ID
    s1 s1 s1 s1 s1
    s2 s2 s2 s2 s2
    Store One Store One Store One Store One Store One
    Store Two  Store Two Store Two Store Two Store Two
  • This is the grid that displays if I search for the word "store" in the grid.
  • I guess you are getting everything as an array,


    try this
    <<<<<<<<<<<<<<<<<<<<<<

    local!entities: {
    {Name:"Store One" ,storeid:"s1" , storeSymbol:"BON" ,storeCity:"Des Moines" ,storeState:"IA"} ,
    {Name:"Store Two" ,storeid: "s2" , storeSymbol:"BTW" ,storeCity:"Boise" ,storeState:"ID"} ,
    {Name:"Store Three" ,storeid: "s3" , storeSymbol:"BTH" ,storeCity:"Charlotte" ,storeState:"NC"} ,
    {Name:"Store Four" ,storeid: "s4" , storeSymbol:"BFR" ,storeCity:"New York" ,storeState:"NY"} ,
    {Name:"Store Five" ,storeid: "s5" , storeSymbol:"BFV" ,storeCity:"Houston" ,storeState:"TX"} ,
    {Name:"Store Six" ,storeid: "s6" , storeSymbol:"BSX" ,storeCity:"Seattle" ,storeState:"WA"} ,
    {Name:"Store Seven" ,storeid: "s7" , storeSymbol:"BSVN",storeCity:"Jersey City",storeState:"NJ"} ,
    {Name:"Store Eight" ,storeid: "s8" , storeSymbol:"BET" ,storeCity:"El Paso" ,storeState:"TX"} ,
    {Name:"Store Nine" ,storeid: "s9" , storeSymbol:"BNI" ,storeCity:"Jersey City",storeState:"NJ"} ,
    {Name:"Store Ten" ,storeid: "s10" , storeSymbol:"BTN" ,storeCity:"Fort Worth" ,storeState:"TX"}
    } ,
    <<<<<<<<<<<<<<<<<<<<<<
    a!forEach(
    items: local!entities ,
    expression: 'type!{urn:com:appian:types:stores}stores_Entity'(
    Name: index(fv!item,"Name","-") ,
    storeid: index(fv!item,"storeid","-") ,
    storeSymbol: index(fv!item,"storeSymbol","-") ,
    storeCity: index(fv!item,"storeCity","-") ,
    storeState: index(fv!item,"storeState","-")
    )
    )
    <<<<<<<<<<<<<<<<<<<<<<
  • Doing that creates a blank grid with no information