Skip to main content
May 2, 2024
Question

getting error please help

  • May 2, 2024
  • 3 replies
  • 0 views

Code:

a!forEach(pv!addedResearchItems_cdt,
 if(
and(rule!APN_isBlank(index(fv!item,"id",{})),rule!APN_isBlank(fv!item.url)),

cast('type!{urn:com:appian:types:gngp}GNGP_RESEARCH_ITEM',updatecdt(fv!item,{file_name:
if(not(isnull(fv!item.file_name)),
fv!item.file_name,
if(not(isnull(fv!item.document_id)),document(todocument(fv!item.document_id), "name") & "." & document(todocument(fv!item.document_id), "extension"),{})
   )})),
 
  fv!item
))

Getting below error:

(Expression evaluation error at function a!forEach: Error in a!forEach() expression during iteration 1: Expression evaluation error at function 'updatecdt' [line 5]: Length of input arrays must equal length of CDT/Dictionary array) (Data Outputs)

Please help to rectify the above error as what code changes needs to be done

    3 replies

    harshk1671
    May 2, 2024

    Try this

    a!forEach(
      pv!addedResearchItems_cdt,
      if(
        and(
          rule!APN_isBlank(index(fv!item, "id", {})),
          rule!APN_isBlank(fv!item.url)
        ),
        cast(
          'type!{urn:com:appian:types:gngp}GNGP_RESEARCH_ITEM',
          a!update(
            fv!item,
            { "file_name" },
            {
              if(
                not(isnull(fv!item.file_name)),
                fv!item.file_name,
                if(
                  not(isnull(fv!item.document_id)),
                  document(todocument(fv!item.document_id), "name") & "." & document(
                    todocument(fv!item.document_id),
                    "extension"
                  ),
                  {}
                )
              )
            }
          )
        ),
        fv!item
      )
    )

    May 2, 2024

    getting below error

    (Expression evaluation error at function a!forEach: Error in a!forEach() expression during iteration 1: Expression evaluation error at function a!update [line 5]: Cannot update GNGP_RESEARCH_ITEM; received 1 keys and 0 values) (Data Outputs)

    harshk1671
    May 2, 2024

    Make sure code returns a value to update or use a null check before
    if(
    not(isnull(fv!item.file_name)),
    fv!item.file_name,
    if(
    not(isnull(fv!item.document_id)),
    document(todocument(fv!item.document_id), "name") & "." & document(
    todocument(fv!item.document_id),
    "extension"
    ),
    {}
    )
    )