Skip to main content
November 5, 2024
Solved

want to remove status and subStatus from the given data ..

  • November 5, 2024
  • 2 replies
  • 0 views

{
{
  requestTypeId: {
    description: "Request Type Unique Identifier",
    type: "integer",
    questionSet: "global",
    required: true,
    typedesc: "Text"
  },
  automationId: {
    description: "Automat Recipe or Campaign Builder Id",
    type: "string",
    questionSet: "global",
    required: true,
    typedesc: "Text"
  },
  status: {
    description: "Automation Source",
    type: "integer",
    questionSet: "global",
    enum: { 157, 158, 159, 160, 161, 162, 163 },
    enumLabels: {
      "Automat",
      "Crossroads",
      "Member Web",
      "Public Directory",
      "Member App",
      "Provider Portal",
      "Faxblast"
    },
    typedesc: "Single-Select"
  },
  subStatus: {
    description: "Reported On Date / Time (format: YYYY-mm-DDTHH:MM:SS)",
    type: "string",
    questionSet: "global",
    typedesc: "Date and Time"
  },
  contactPhoneNumber: {
    description: "Contact Phone Number",
    type: "string",
    questionSet: "global",
    typedesc: "Text"
  },
  contactEmail: {
    description: "Contact Email",
    type: "string",
    questionSet: "global",
    typedesc: "Text"
  },
  dctLink: {
    description: "DCT Link",
    type: "string",
    questionSet: "global",
    typedesc: "Text"
  },
  insuranceMarket: {
    description: "Insurance Market",
    type: "string",
    questionSet: "global",
    enum: {
      "Individual",
      "Medicare Advantage",
      "Self Insured",
      "Small Group"
    },
    enumLabels: {
      "Individual",
      "Medicare Advantage",
      "Self Insured",
      "Small Group"
    },
    typedesc: "Single-Select"
  }
}}

Best answer by harmanjots9955

a!localVariables(
local!keys: a!keys(ri!data[1]),
a!forEach(
items: remove(
{ local!keys },
wherecontains({ "status", "subStatus" }, local!keys)
),
expression: index(ri!data[1], fv!item, {})
)
)

2 replies

November 5, 2024

a!localVariables(
local!keys: a!keys(ri!data[1]),
a!forEach(
items: remove(
{ local!keys },
wherecontains({ "status", "subStatus" }, local!keys)
),
expression: index(ri!data[1], fv!item, {})
)
)

stefanhelzle0001
Brainy
November 5, 2024

A very compact solution to your problem. Please check the documentation for a!keys(), a!update(), reduce(), merge() and apply().

The idea is to create a new map from scratch and copy only the required fields from the old map.

a!localVariables(
  local!data: {
      requestTypeId: {
        description: "Request Type Unique Identifier",
        type: "integer",
        questionSet: "global",
        required: true,
        typedesc: "Text"
      },
      automationId: {
        description: "Automat Recipe or Campaign Builder Id",
        type: "string",
        questionSet: "global",
        required: true,
        typedesc: "Text"
      },
      status: {
        description: "Automation Source",
        type: "integer",
        questionSet: "global",
        enum: { 157, 158, 159, 160, 161, 162, 163 },
        enumLabels: {
          "Automat",
          "Crossroads",
          "Member Web",
          "Public Directory",
          "Member App",
          "Provider Portal",
          "Faxblast"
        },
        typedesc: "Single-Select"
      },
      subStatus: {
        description: "Reported On Date / Time (format: YYYY-mm-DDTHH:MM:SS)",
        type: "string",
        questionSet: "global",
        typedesc: "Date and Time"
      },
      contactPhoneNumber: {
        description: "Contact Phone Number",
        type: "string",
        questionSet: "global",
        typedesc: "Text"
      },
      contactEmail: {
        description: "Contact Email",
        type: "string",
        questionSet: "global",
        typedesc: "Text"
      },
      dctLink: {
        description: "DCT Link",
        type: "string",
        questionSet: "global",
        typedesc: "Text"
      },
      insuranceMarket: {
        description: "Insurance Market",
        type: "string",
        questionSet: "global",
        enum: {
          "Individual",
          "Medicare Advantage",
          "Self Insured",
          "Small Group"
        },
        enumLabels: {
          "Individual",
          "Medicare Advantage",
          "Self Insured",
          "Small Group"
        },
        typedesc: "Single-Select"
      }
    },
  local!reducedFields: difference(a!keys(local!data), {"status", "subStatus"}),
  reduce(
    a!update(_,_,_),
    a!map(), /* Start with an empty list */
    merge( /* Create a list of tuples containing the field name and the field's value */
      local!reducedFields,
      apply(index(local!data,_,null), local!reducedFields)
    )
  )
)