Cannot update List of GAI Workflow at 4 keys; length of assign value list (46) does not match length of the list to update (4)

Certified Senior Developer

Expression evaluation error at function a!update [line 36]: Cannot update List of GAI Workflow at 4 keys; length of assign value list (46) does not match length of the list to update (4).

I am getting this error while executing expression rule, How can i fixed that ?

i have paste my code

a!localVariables(
  local!currGrantWorkflow: rule!GAI_getWorkflow(workflowId: ri!workflowId).data,
  local!refDecTree: if(
    rule!SCO_isBoolNotEmptyAndTrue(
      local!currGrantWorkflow['recordType!{f8c3f153-12d0-4850-97d9-bd6878795255}GAI Workflow.fields.{5febe064-3783-49f6-ac2c-1f69ce22e5b5}isCustomWorkflow']
    ),
    null,
    rule!GAI_getRefWorkflowDecisionTree(
      currStatusId: local!currGrantWorkflow['recordType!{f8c3f153-12d0-4850-97d9-bd6878795255}GAI Workflow.fields.{7cd66171-e9d3-45ae-9967-fe88fbd9f594}fkWorkflowTypeStatusId'],
      taskDecisionId: ri!taskDecisionId
    ).data
  ),
  local!customDecTree: if(
    rule!SCO_isBoolBlankOrEmptyOrFalse(
      local!currGrantWorkflow['recordType!{f8c3f153-12d0-4850-97d9-bd6878795255}GAI Workflow.fields.{5febe064-3783-49f6-ac2c-1f69ce22e5b5}isCustomWorkflow']
    ),
    null,
    rule!GAI_getCustomWorkflowDecisionTree(
      currStatusId: local!currGrantWorkflow['recordType!{f8c3f153-12d0-4850-97d9-bd6878795255}GAI Workflow.fields.{7cd66171-e9d3-45ae-9967-fe88fbd9f594}fkWorkflowTypeStatusId'],
      taskDecisionId: ri!taskDecisionId
    )
  ),
  local!nextStatusId: if(
    rule!SCO_isBoolNotEmptyAndTrue(
      local!currGrantWorkflow['recordType!{f8c3f153-12d0-4850-97d9-bd6878795255}GAI Workflow.fields.{5febe064-3783-49f6-ac2c-1f69ce22e5b5}isCustomWorkflow']
    ),
    local!customDecTree['recordType!{a40eed83-2094-46ce-aef5-fca7da4f29e8}GAI Custom Workflow Decision Tree.fields.{29f44dde-1de1-4125-8363-54dcf85519c6}fkNextWorkflowStatusId'],
    local!refDecTree['recordType!{c50c1c2c-8759-4483-9f95-8c12ba42f4be}GAI Ref Workflow Decision Tree.fields.{3bf65603-7f29-486f-b7cf-1a53d94ed2c0}fkNextWorkflowStatusId']
  ),
  local!newGrantWorkflow: if(
    local!nextStatusId = local!currGrantWorkflow['recordType!{f8c3f153-12d0-4850-97d9-bd6878795255}GAI Workflow.fields.{7cd66171-e9d3-45ae-9967-fe88fbd9f594}fkWorkflowTypeStatusId'],
    null,
    if(
      a!isNullOrEmpty(local!nextStatusId),
      local!currGrantWorkflow,
      a!update(
        local!currGrantWorkflow,
        {
          'recordType!{f8c3f153-12d0-4850-97d9-bd6878795255}GAI Workflow.fields.{559ab16f-8958-4603-84a2-f485f5b0651a}assignedTs',
          'recordType!{f8c3f153-12d0-4850-97d9-bd6878795255}GAI Workflow.fields.{7cd66171-e9d3-45ae-9967-fe88fbd9f594}fkWorkflowTypeStatusId',
          'recordType!{f8c3f153-12d0-4850-97d9-bd6878795255}GAI Workflow.fields.{77ff57c7-14f7-4dfc-a103-81afaee4e8d8}updateTs',
          'recordType!{f8c3f153-12d0-4850-97d9-bd6878795255}GAI Workflow.fields.{f007d4d7-7ee0-4736-98f4-c34f3aac3dfb}updateUsr'
        },
        {
          now(),
          local!nextStatusId,
          now(),
          null
        }
      )
    )
  ),
  a!map(
    currGrantWorkflow: local!currGrantWorkflow,
    newGrantWorkflow: local!newGrantWorkflow
  )
)

  Discussion posts and replies are publicly visible

  • 0
    Certified Senior Developer
    in reply to Stefan Helzle

    Hii Stefan, i am getting same error , how to resolve this  ?

  • 0
    Certified Lead Developer
    in reply to Sudhir Singh

    This is really confusing! You mean that you have the same error than in your other post !?!? And it does not help to create multiple posts for the same issue.

    If your local "local!currGrantWorkflow" contains more than a single item, you need to use a foreach() to perform the update on each item.

  •  It seems you have issues in the a!update function.

    Try this

      local!currGrantWorkflow: rule!GAI_getWorkflow(workflowId: ri!workflowId).data,
      local!nextStatusId: if(
        rule!SCO_isBoolNotEmptyAndTrue(
          local!currGrantWorkflow['recordType!{f8c3f153-12d0-4850-97d9-bd6878795255}GAI Workflow.fields.{5febe064-3783-49f6-ac2c-1f69ce22e5b5}isCustomWorkflow']
        ),
        local!customDecTree['recordType!{a40eed83-2094-46ce-aef5-fca7da4f29e8}GAI Custom Workflow Decision Tree.fields.{29f44dde-1de1-4125-8363-54dcf85519c6}fkNextWorkflowStatusId'],
        local!refDecTree['recordType!{c50c1c2c-8759-4483-9f95-8c12ba42f4be}GAI Ref Workflow Decision Tree.fields.{3bf65603-7f29-486f-b7cf-1a53d94ed2c0}fkNextWorkflowStatusId']
      ),
      local!newGrantWorkflow: if(
        local!nextStatusId = local!currGrantWorkflow['recordType!{f8c3f153-12d0-4850-97d9-bd6878795255}GAI Workflow.fields.{7cd66171-e9d3-45ae-9967-fe88fbd9f594}fkWorkflowTypeStatusId'],
        null,
        if(
          a!isNullOrEmpty(local!nextStatusId),
          local!currGrantWorkflow,
          a!update(
            local!currGrantWorkflow,
            {
              'recordType!{f8c3f153-12d0-4850-97d9-bd6878795255}GAI Workflow.fields.{559ab16f-8958-4603-84a2-f485f5b0651a}assignedTs': now(),
              'recordType!{f8c3f153-12d0-4850-97d9-bd6878795255}GAI Workflow.fields.{7cd66171-e9d3-45ae-9967-fe88fbd9f594}fkWorkflowTypeStatusId': local!nextStatusId,
              'recordType!{f8c3f153-12d0-4850-97d9-bd6878795255}GAI Workflow.fields.{77ff57c7-14f7-4dfc-a103-81afaee4e8d8}updateTs': now(),
              'recordType!{f8c3f153-12d0-4850-97d9-bd6878795255}GAI Workflow.fields.{f007d4d7-7ee0-4736-98f4-c34f3aac3dfb}updateUsr': null
            }
          )
        )
      )
    )```
    
    Make sure to replace the placeholders with the appropriate values from your application. This adjusted version should help prevent the error you're encountering.
    

  • 0
    Certified Lead Developer

    check the update function syntax. second parameter should be index.