Error while submitting the form. save values error kindly help

Code : 

a!buttonWidget(
label: "Save & Exit",
tooltip: "Click here to save the data & resume the task later",
saveInto: {
a!save(ri!Save,true),a!save(ri!Submit,false),
a!forEach(
items: local!samtask,
expression: {
if(
isnull(fv!item.creationDate),
a!save(
fv!item.creationDate,today()
)
, null
),
if(isnull(fv!item.lastUpdateDate), a!save(
fv!item.lastUpdateDate,today()
), null)

,
if(isnull(fv!item.createdby),a!save(
fv!item.createdby,(user(loggedInUser(),"firstName")&" "&user(loggedInUser(),"lastName"))
), null),
if(isnull(fv!item.lastUpdatedby),a!save(
fv!item.lastUpdatedby,(user(loggedInUser(),"firstName")&" "&user(loggedInUser(),"lastName"))
), null),
if(isnull(fv!item.comments) ,a!save(
fv!item.comments,"Row created at CCA task interface by user"
), null)

}
),
a!save(ri!SamTask,local!samtask)

},
submit:true,
size: "STANDARD",
style: "PRIMARY",
disabled:and(a!forEach(
items: local!samtask,
expression: fv!item.istaskdone
))

ERROR : Could not display interface. Please check definition and inputs. Interface Definition: Expression evaluation error [evaluation ID = 0IAGCEKD] : An error occurred while executing a save: Expression evaluation error: You must specify a variable to save into, such as ri!name << fn!sum. Received: List of Text String.

Kindly help me Thanks

  Discussion posts and replies are publicly visible

  • The main issue I see is that you have a bunch of if() statements inside of your a!forEach() that resolve to either a save or null. Having null is not valid as a save - you must either return a variable, a!save() or an empty list. Can you try to swap out all the instances of returning null with {} instead?

  • Just curious - does it work without the a!forEach()? I'm wondering if you also have to somehow flatten the result of the forEach, since maybe it's returning a list of lists or something. For instance, you could try to use fn!reject to remove the empty lists or null values.

    One other hacky way that I bet would work - you could also try to always save a value in each of the saves, but if the value already exists simply save the new value as the previous value. For example you could try this:

    a!save(
      target: fv!item.creationDate,
      value: if(
        isnull(fv!item.creationDate),
        today(),
        fv!item.creationDate
      )
    )

  • Yes, rejecting the null values will allow the a!save items to function properly:

    a!buttonWidget(
      label: "Save & Exit",
      tooltip: "Click here to save the data & resume the task later",
      saveInto: {
        a!save(ri!Save,true),a!save(ri!Submit,false),
        fn!reject(
          fn!isnull,
          a!forEach(
            items: local!samtask,
            expression: {
              if(
                isnull(fv!item.creationDate),
                a!save(
                  fv!item.creationDate,today()
                )
                , null
              ),
              if(isnull(fv!item.lastUpdateDate), a!save(
                fv!item.lastUpdateDate,today()
              ), null)
    
              ,
              if(isnull(fv!item.createdby),a!save(
                fv!item.createdby,(user(loggedInUser(),"firstName")&" "&user(loggedInUser(),"lastName"))
              ), null),
              if(isnull(fv!item.lastUpdatedby),a!save(
                fv!item.lastUpdatedby,(user(loggedInUser(),"firstName")&" "&user(loggedInUser(),"lastName"))
              ), null),
              if(isnull(fv!item.comments) ,a!save(
                fv!item.comments,"Row created at CCA task interface by user"
              ), null)
    
            }
          )
        ),
        a!save(ri!SamTask,local!samtask)
    
      },
      submit:true,
      size: "STANDARD",
      style: "PRIMARY",
      disabled:and(a!forEach(
        items: local!samtask,
        expression: fv!item.istaskdone
      ))

  • 0
    A Score Level 1
    in reply to Chris

    I am also facing the same error when I am storing multiple documents for each list in the same interface can you please suggest me please.when I am using the below code the value is not getting stored, I unable to identify the error.

    .

    a!gridLayout(
                            label:"",
                            headerCells:{
                              a!gridLayoutHeaderCell(label:"Upload"),
                              a!gridLayoutHeaderCell(label:"DocDescription"),
                              a!gridLayoutHeaderCell(label:" ")
                            },
                            columnConfigs:{},
                            rows:{
                              a!forEach(
                                items:{
                                 
                                if(
                                 ri!isReadOnly,
                                 ri!Document,
                                
                                 if(rule!FCO_isNullOrBlank(ri!Document),
                                 null(),
                                 ri!Document[wherecontains(local!mappingId,ri!Document.mappingKey)]
                                 )
                                )},
                                
                                   expression:a!gridRowLayout(
                                  contents:{
                                    a!fileUploadField(
                                      label:"Upload Document",
                                      target:cons!SHA_FOLDER,
                                      maxSelections:1, 
                                      value:fv!item.appianDocId,
                                      saveInto:{
                                        if(
                                          isnull(fv!item.appianDocId),
                                          ri!Document,
                                        fv!item.appianDocId
                                        )
                                       },
                                        
                                        
                                        
                                     
                                    
                                    
                                    /*a!forEach(*/
                                      /*ri!Document,index(ri!Document,"appianDocId",{}))),*/
                                        /*index(ri!Document,"appianDocId",null)*/
                                        /*a!save(ri!Document,fv!item.appianDocId)*/
                                       /*a!save(local!Doc, index(ri!Document,fv!item.appianDocId,null))*/
    
                                      
                                      required: true(),
                                      requiredMessage:"Please upload document",
                                      disabled:ri!isReadOnly
                                    ),
                                    a!textField(
                                      label:"docdescription",
                                      placeholder:"enter doc description",
                                      value:fv!item.docDescription,
                                      saveInto:a!save(local!Doc,fv!item.docDescription),
                                     required: true(),
                                      readOnly:ri!isReadOnly
    
                                    ),
                                    a!richTextDisplayField(
                                      labelPosition: "",
                                      value: {
                                        a!richTextIcon(
                                          icon:"trash-o",
                                          link: a!dynamicLink(
                                            value:fv!index,
                                            saveInto:a!save(ri!Document,remove(ri!Document,fv!index))
    
                                          ),
                                          color:"NEGATIVE",
                                          size:"STANDARD"
                                        )
                                      }
    
                                    )
    
                                  }
                                )
                              )
                            },
                            selectionValue:ri!Document,
                            selectionSaveInto:ri!Document,
                            selectable: {},
                            selectionRequired:false,
                            selectionDisabled:{},
                            addRowLink:a!dynamicLink(
                              label: "Upload New File",
                              value:true(),
                              saveInto:{
                                /*a!save(*/
                                /*ri!Document,append(ri!Document,local!document) */
                                /*),*/
                                a!save(
                                  ri!Document,
                                  append(
                                    ri!Document,/*empty set*/
                                    a!forEach(
                                      index(reverse({save!value}),1),/*component updated values*/
                                      'type!{urn:com:appian:types:SHA}SHA_document'(
                                        mappingKey: local!mappingId
                                      )))),
                                      local!Document
    
                              }
                            ),
                            validations: {},
                            shadeAlternateRows:true
                          )

  • It seems weird to me that in most of your fields you're saving directly into your original variable, like ri!document or local!doc. Remember, your components exist inside of a!forEach(), so each component should likely only save to one of the rows - not all of the rows. Generally you would do this by either saving directly to fv!item or using fv!index to save to a specific item in a list, like:

    a!save(
      target: local!myDoc.date[fv!index]
      value: today()
    )