how can i create map or key value pairs of existing attached code.

a!localVariables(
  
  local!actualData: 	
  {a!map(standardFieldId: 277, categoryId: 350, ticketTypeId: 439, providerTypeLookupRefId: 42, assignee: fn!touser("egbeyong@test.com"), slaId: 379, priorityLookupRefId: 30, statusLookupRefId: 39, subStatusLookupRefId: 49, description: "Description Auto fill", submitterLookupRefId: 8, dueDate: fn!date(2024, 9, 25), isActive: true, createdBy: fn!touser("test.test@test.com"), createdDt: fn!datetime(2024, 9, 25, 10, 26, 55, 0), updatedBy: fn!touser("test.test@test.com"), updatedDt: fn!datetime(2024, 9, 25, 10, 27, 2, 0), ticketTypeName: "Provider Data Edit", derivedTicketId: "PRVDATAEDIT-277", dueDateSpecial: fn!date(2024, 9, 25), daysLeft: -5)},
  local!data: 	
  {a!map(escalationFieldId: 14069, escalationPathwayId: 387, isRequired: true, visibilityStatusLookupRefId: fn!tointeger(null), autofillSourceFieldName: "description", autofillDestFieldName: "code", bigQueryRule: fn!tointeger(null), automationTypeLookupId: 40, isVisible: true, isActive: true, createdBy: "test.test@test.com", createdDt: fn!datetime(2024, 9, 30, 3, 54, 20, 0), updatedBy: "test.test@test.com", updatedDt: fn!datetime(2024, 9, 30, 3, 54, 20, 0), destTicketTypeId: 268, uuid: "f03b6999-c073-43b7-a584-04aa5e988710"), a!map(escalationFieldId: 14034, escalationPathwayId: 387, isRequired: true, visibilityStatusLookupRefId: fn!tointeger(null), autofillSourceFieldName: "description", autofillDestFieldName: "description", bigQueryRule: fn!tointeger(null), automationTypeLookupId: 40, isVisible: true, isActive: true, createdBy: "test.test@test.com", createdDt: fn!datetime(2024, 9, 30, 3, 54, 20, 0), updatedBy: "test.test@test.com", updatedDt: fn!datetime(2024, 9, 30, 3, 54, 20, 0), destTicketTypeId: 268, uuid: "0038a9e9-e0d3-4c36-8b50-eb97ecbbf39e"), a!map(escalationFieldId: 14032, escalationPathwayId: 387, isRequired: true, visibilityStatusLookupRefId: fn!tointeger(null), autofillSourceFieldName: "summary", autofillDestFieldName: "summary", bigQueryRule: fn!tointeger(null), automationTypeLookupId: 40, isVisible: true, isActive: true, createdBy: "test.test@test.com", createdDt: fn!datetime(2024, 9, 30, 3, 54, 20, 0), updatedBy: "test.test@test.com", updatedDt: fn!datetime(2024, 9, 30, 3, 54, 20, 0), destTicketTypeId: 268, uuid: "6c092428-7b84-465b-8131-de5d2f83477e")},
  local!actualKeys: local!3data.autofillDestFieldName,
  index(
    local!actualData,
    local!data.autofillSourceFieldName,
    {}
  ), /* returns Values of matching autofillSourceFieldName of local!data  from local!actualdata's description(Key)*/

  /*just taking an example of first map present in local!data if in local!data value of autofillSourceFieldName which is description in first map is present in the local!actualdata then key "description"  then Key value pair should be of {code:"Description Auto Fill"}code is autofillDestFieldName in local!data*/

)

Hi All ,

Let me know how should i prepare the map or key value pairs dynamically of mentioned code 

Thanks 

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer

    I copied your code and really tried to understand what you want to achieve. I came up with this, but not sure whether it is correct.

    a!localVariables(
      local!actualData: {
        a!map(
          standardFieldId: 277,
          categoryId: 350,
          ticketTypeId: 439,
          providerTypeLookupRefId: 42,
          assignee: fn!touser("egbeyong@test.com"),
          slaId: 379,
          priorityLookupRefId: 30,
          statusLookupRefId: 39,
          subStatusLookupRefId: 49,
          description: "Description Auto fill",
          submitterLookupRefId: 8,
          dueDate: fn!date(2024, 9, 25),
          isActive: true,
          createdBy: fn!touser("test.test@test.com"),
          createdDt: fn!datetime(2024, 9, 25, 10, 26, 55, 0),
          updatedBy: fn!touser("test.test@test.com"),
          updatedDt: fn!datetime(2024, 9, 25, 10, 27, 2, 0),
          ticketTypeName: "Provider Data Edit",
          derivedTicketId: "PRVDATAEDIT-277",
          dueDateSpecial: fn!date(2024, 9, 25),
          daysLeft: - 5
        )
      },
      local!data: {
        a!map(
          escalationFieldId: 14069,
          escalationPathwayId: 387,
          isRequired: true,
          visibilityStatusLookupRefId: fn!tointeger(null),
          autofillSourceFieldName: "description",
          autofillDestFieldName: "code",
          bigQueryRule: fn!tointeger(null),
          automationTypeLookupId: 40,
          isVisible: true,
          isActive: true,
          createdBy: "test.test@test.com",
          createdDt: fn!datetime(2024, 9, 30, 3, 54, 20, 0),
          updatedBy: "test.test@test.com",
          updatedDt: fn!datetime(2024, 9, 30, 3, 54, 20, 0),
          destTicketTypeId: 268,
          uuid: "f03b6999-c073-43b7-a584-04aa5e988710"
        ),
        a!map(
          escalationFieldId: 14034,
          escalationPathwayId: 387,
          isRequired: true,
          visibilityStatusLookupRefId: fn!tointeger(null),
          autofillSourceFieldName: "description",
          autofillDestFieldName: "description",
          bigQueryRule: fn!tointeger(null),
          automationTypeLookupId: 40,
          isVisible: true,
          isActive: true,
          createdBy: "test.test@test.com",
          createdDt: fn!datetime(2024, 9, 30, 3, 54, 20, 0),
          updatedBy: "test.test@test.com",
          updatedDt: fn!datetime(2024, 9, 30, 3, 54, 20, 0),
          destTicketTypeId: 268,
          uuid: "0038a9e9-e0d3-4c36-8b50-eb97ecbbf39e"
        ),
        a!map(
          escalationFieldId: 14032,
          escalationPathwayId: 387,
          isRequired: true,
          visibilityStatusLookupRefId: fn!tointeger(null),
          autofillSourceFieldName: "summary",
          autofillDestFieldName: "summary",
          bigQueryRule: fn!tointeger(null),
          automationTypeLookupId: 40,
          isVisible: true,
          isActive: true,
          createdBy: "test.test@test.com",
          createdDt: fn!datetime(2024, 9, 30, 3, 54, 20, 0),
          updatedBy: "test.test@test.com",
          updatedDt: fn!datetime(2024, 9, 30, 3, 54, 20, 0),
          destTicketTypeId: 268,
          uuid: "6c092428-7b84-465b-8131-de5d2f83477e"
        )
      },
      a!forEach(
        items: local!data,
        expression: if(
          contains(a!keys(local!actualData[1]), fv!item.autofillSourceFieldName),
          a!update(
            a!map(),
            fv!item.autofillDestFieldName,
            local!actualData[1][fv!item.autofillSourceFieldName]
          ),
          {}
        )
      )  
    )

Reply
  • +1
    Certified Lead Developer

    I copied your code and really tried to understand what you want to achieve. I came up with this, but not sure whether it is correct.

    a!localVariables(
      local!actualData: {
        a!map(
          standardFieldId: 277,
          categoryId: 350,
          ticketTypeId: 439,
          providerTypeLookupRefId: 42,
          assignee: fn!touser("egbeyong@test.com"),
          slaId: 379,
          priorityLookupRefId: 30,
          statusLookupRefId: 39,
          subStatusLookupRefId: 49,
          description: "Description Auto fill",
          submitterLookupRefId: 8,
          dueDate: fn!date(2024, 9, 25),
          isActive: true,
          createdBy: fn!touser("test.test@test.com"),
          createdDt: fn!datetime(2024, 9, 25, 10, 26, 55, 0),
          updatedBy: fn!touser("test.test@test.com"),
          updatedDt: fn!datetime(2024, 9, 25, 10, 27, 2, 0),
          ticketTypeName: "Provider Data Edit",
          derivedTicketId: "PRVDATAEDIT-277",
          dueDateSpecial: fn!date(2024, 9, 25),
          daysLeft: - 5
        )
      },
      local!data: {
        a!map(
          escalationFieldId: 14069,
          escalationPathwayId: 387,
          isRequired: true,
          visibilityStatusLookupRefId: fn!tointeger(null),
          autofillSourceFieldName: "description",
          autofillDestFieldName: "code",
          bigQueryRule: fn!tointeger(null),
          automationTypeLookupId: 40,
          isVisible: true,
          isActive: true,
          createdBy: "test.test@test.com",
          createdDt: fn!datetime(2024, 9, 30, 3, 54, 20, 0),
          updatedBy: "test.test@test.com",
          updatedDt: fn!datetime(2024, 9, 30, 3, 54, 20, 0),
          destTicketTypeId: 268,
          uuid: "f03b6999-c073-43b7-a584-04aa5e988710"
        ),
        a!map(
          escalationFieldId: 14034,
          escalationPathwayId: 387,
          isRequired: true,
          visibilityStatusLookupRefId: fn!tointeger(null),
          autofillSourceFieldName: "description",
          autofillDestFieldName: "description",
          bigQueryRule: fn!tointeger(null),
          automationTypeLookupId: 40,
          isVisible: true,
          isActive: true,
          createdBy: "test.test@test.com",
          createdDt: fn!datetime(2024, 9, 30, 3, 54, 20, 0),
          updatedBy: "test.test@test.com",
          updatedDt: fn!datetime(2024, 9, 30, 3, 54, 20, 0),
          destTicketTypeId: 268,
          uuid: "0038a9e9-e0d3-4c36-8b50-eb97ecbbf39e"
        ),
        a!map(
          escalationFieldId: 14032,
          escalationPathwayId: 387,
          isRequired: true,
          visibilityStatusLookupRefId: fn!tointeger(null),
          autofillSourceFieldName: "summary",
          autofillDestFieldName: "summary",
          bigQueryRule: fn!tointeger(null),
          automationTypeLookupId: 40,
          isVisible: true,
          isActive: true,
          createdBy: "test.test@test.com",
          createdDt: fn!datetime(2024, 9, 30, 3, 54, 20, 0),
          updatedBy: "test.test@test.com",
          updatedDt: fn!datetime(2024, 9, 30, 3, 54, 20, 0),
          destTicketTypeId: 268,
          uuid: "6c092428-7b84-465b-8131-de5d2f83477e"
        )
      },
      a!forEach(
        items: local!data,
        expression: if(
          contains(a!keys(local!actualData[1]), fv!item.autofillSourceFieldName),
          a!update(
            a!map(),
            fv!item.autofillDestFieldName,
            local!actualData[1][fv!item.autofillSourceFieldName]
          ),
          {}
        )
      )  
    )

Children