a!gridImageColumn is giving issue

Hi ,

I am facing some issue after adding one condition to below working code. After adding its returning document as  null. 

Kindly help me and correct me where i am missing in the below code snippet.

Kindly find below working and non working code and error message .

-------------------------------Working code----------------------------

a!gridImageColumn(
label: "",
size: "ICON",
data: if(rule!APN_isEmpty(local!testsubset.data),{},apply(
a!documentImage(document: _,caption: _),
merge(
apply(a!iconIndicator, {if(todate(local!testsubset.data.strDate)>today(),"Hello", "Hii")}),
apply(touniformstring(_),{
merge(
if(todate(local!testsubset.data.strDate)>today(),"Hi to all","Hello to all"),
todate(local!testsubset.data.strDate))})
)
))
)

-------------------------------- Added code which is giving below error---------------

a!gridImageColumn(
label: "",
size: "ICON",
data: if(rule!APN_isEmpty(local!testsubset.data),{},apply(
a!documentImage(document: _,caption: _),
merge(
apply(a!iconIndicator, {if(todate(local!testsubset.data.strDate)>today(),"Hello", "Hii")}),
apply(touniformstring(_),{
merge({
if(count(local!testsubsetFinal)>0,
if(local!testsubset.data.id=local!testsubsetFinal.id,"Hi to all","Hello to all"),"Date Implemented"),
todate(local!testsubset.data.strDate)})})
)
))
)



Error Evaluating UI Expression
Expression evaluation error in rule 'Test_Rule' (called by rule 'Master_Rule') at function a!gridField [line 126]: The image at index 13 in an grid component [label=“”] has an invalid value for “document”. “document” must not be null.

  Discussion posts and replies are publicly visible

Parents
  • If you have access to use the a!forEach function try that instead. I find forEach much easier to use for looping. Something along the lines of a!forEach(items: local!testsubset.data, expression : a!documentImage( /* code to determine the document to display*/ )). You shouldn't need to use the merge commands so it should simplify your code - I'd also suggest using proper documents to start with as I'm not sure the values you're passing in are actual document icons ?    

  • These are icons only. But by just changing if condition its not working. I tried to simply put "true" also in if condition not working.

    Saying it should be list in merge function. I had put {} then its started saying document object is null.

    I am not understanding why that is tightly bounded with this condition. I can't change this code pattern as of now.

  • Can you post the full code snippet as I've just tried to create a dummy interface in my sandpit and I'm getting an error message around 

    Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error at function a!iconIndicator [line 16]: Invalid value for “icon”. Received: Hii. Supported values are:

  • I've now managed to recreate the issue locally - will see if I can help with the code.

  • I've experimented and have manged to create this logic - which works. See if you can adapt it to your use case. 

    = load(
      local!testsubsetFinal: todatasubset(
        {
          {
            id: 1
          },
          {
            id: 3
          }
        }
      ),
      local!testsubset: todatasubset(
        {
          {
            id: 1,
            strDate: date(
              2019,
              05,
              30
            )
          },
          {
            id: 2,
            strDate: date(
              2019,
              06,
              10
            )
          }
        }
      ),
      a!gridField(
        label: "",
        columns: {
          a!gridImageColumn(
            label: "",
            size: "ICON",
            data: a!forEach(
              items: local!testsubset.data,
              expression: a!documentImage(
                document: a!iconIndicator(
                  if(todate(fv!item.strDate) > today(), "FACE_HAPPY", "FACE_SAD")
                ),
               caption: if(count(local!testsubsetFinal.data)>0, 
                if(fv!item.id=local!testsubsetFinal.data.id,"Hi to all ","Hello to all "),"Date Implemented " & todate(fv!item.strDate)))
                
              )
            )
            
            
            
          
          
        },
        totalCount: length(local!testsubset.data),
        value: a!pagingInfo(
          startIndex: 1,
          batchSize: 10
        )
      )
    )

Reply
  • I've experimented and have manged to create this logic - which works. See if you can adapt it to your use case. 

    = load(
      local!testsubsetFinal: todatasubset(
        {
          {
            id: 1
          },
          {
            id: 3
          }
        }
      ),
      local!testsubset: todatasubset(
        {
          {
            id: 1,
            strDate: date(
              2019,
              05,
              30
            )
          },
          {
            id: 2,
            strDate: date(
              2019,
              06,
              10
            )
          }
        }
      ),
      a!gridField(
        label: "",
        columns: {
          a!gridImageColumn(
            label: "",
            size: "ICON",
            data: a!forEach(
              items: local!testsubset.data,
              expression: a!documentImage(
                document: a!iconIndicator(
                  if(todate(fv!item.strDate) > today(), "FACE_HAPPY", "FACE_SAD")
                ),
               caption: if(count(local!testsubsetFinal.data)>0, 
                if(fv!item.id=local!testsubsetFinal.data.id,"Hi to all ","Hello to all "),"Date Implemented " & todate(fv!item.strDate)))
                
              )
            )
            
            
            
          
          
        },
        totalCount: length(local!testsubset.data),
        value: a!pagingInfo(
          startIndex: 1,
          batchSize: 10
        )
      )
    )

Children