Value cannot be cast to com.appiancorp.core.data.Variant

Hello,

I have a paragraph field to enter some description about the documents.For each document,the description should be shown and saved based of document id.

I am facing some weird error which i could not debug.

Please help me what the error is about.

No environmental issues.

load(
  local!documentDetails: rule!RCO_QRY_getDocumentsByDocId(
    docIds: {ri!document},
    isIndexIntoData: true,
    pagingInfo:topaginginfo(
      1,1
    )
  ),
  local!displaySaveSuccess: false,
  {
    a!sectionLayout(
      contents: {
        rule!RCO_displayBannerHeadline(
          isBannerHeadlineVisible: local!displaySaveSuccess,
          style: "SUCCESS",
          message: "Document Details Successfully Saved",
          icon: "check"
        ),
              a!columnsLayout(
          columns: {
            a!columnLayout(
              contents: {
                a!richTextDisplayField(
                  value: {
                    a!richTextItem(
                      text: "Document Details: "& ri!document,
                      color: "STANDARD",
                      size: "MEDIUM",
                      style: {
                        "STRONG"
                      }
                    )
                  }
                ),
               a!paragraphField(
                  instructions: len(
                    index(
                      local!documentDetails,
                      "documentDetails",
                      {}
                    )
                  ) & "1/150",
                  value: index(local!documentDetails,"documentDetails",null),
                  saveInto:{a!save(local!documentDetails.documentDetails, save!value)},
                  validations: if(
                    len(
                      index(
                        local!documentDetails,
                        "documentDetails",
                        0
                      )
                    ) > 150,
                    "Case Details must be no longer than 150 characters",
                    {}
                  )
                ),
              },
              width: "AUTO"
            )
          },
          alignVertical: "BOTTOM"
        ),
        a!buttonLayout(
          primaryButtons: a!buttonWidget(
            label: "SAVE DOCUMENT DETAILS",
             saveInto: {
              a!writeToDataStoreEntity(
                dataStoreEntity: cons!RCO_DSE_DOCUMENTS,
                valueToStore: local!documentDetails,
                onSuccess: {
                  a!save(
                    local!documentDetails,
                    fv!storedValues
                  ),
                  a!save(
                    local!displaySaveSuccess,
                    true
                  )
                }
              )
             
            }
          )
        )
      }
      /*showWhen: not(rule!APN_isEmpty(local!documentDetails))*/
    )
  }
)

Thanks

  Discussion posts and replies are publicly visible

Parents
  • Hm... it's hard to say for sure without having access to the dependencies, but my first guess would be that rule!RCO_QRY_getDocumentsByDocId is returning data in the wrong format for how you're then trying to use it. 

  • Hello Eliot,

    while the query seems to be working fine and returning me required value.

    /*Name: RCO_QRY_getDocumentsByDocId*/
    load(
      local!datasubset: if(rule!APN_isEmpty(ri!docIds),
        todatasubset({}),
        a!queryEntity(
          entity: cons!RCO_DSE_DOCUMENTS,
          query: a!query(
            selection: if(rule!APN_isBlank(ri!columns),
              {},
              a!querySelection(
                columns:  a!forEach(ri!columns,
                  a!queryColumn(
                  field: fv!item
                  )
                )
              )
            ),
            filter: a!queryFilter(
              field: "docId",
              operator: "in",
              value: ri!docIds
            ),
            pagingInfo: if(rule!APN_isBlank(ri!pagingInfo),
              a!pagingInfo(1, -1),
              ri!pagingInfo
            )
          )    
        )
      ),
      if(ri!isIndexIntoData, index(local!datasubset, "data", {}), local!datasubset)
    )

  • After looking at it a bit more, the issue is on line 44 with your save. save!value in this case is a value (like a String), and you're trying to save that into a Variant or List of Variant. If you do something like

     

    a!textField(
        label: "Text",
        labelPosition: "ABOVE",
        value: index(local!documentDetails,"documentDetails",null),
        saveInto: a!save(ri!text1,typeof(save!value)),
        refreshAfter: "UNFOCUS",
        validations: {}
      )

    and compare the typeof for save!value and local!documentDetails.documentDetails , I suspect you'll see that they are different types. One thing you could do that might work instead, particularly since it seems like your documentDetails property is just some text, would be to have a rule input of type text, and save the value into that. 

Reply Children
No Data