Skip to main content
Inspiring
Oct 18, 2023 3:47 PM UTC
Question

Data manipulation in order to make record type

Hi All ,

In the attached Screenshot, two values are shown for the project ID, and I want the custom field name to repeat itself twice and the custom field id to repeat itself twice as well. 

I've added code snippet to what I've currently written for reference  and 

Output should look like this 


map

project id  list of number(integer)-2 items
   18800 (number(integer))

   12405 (number(integer))

customFieldName  list of (Text)-2 items

   "2nd Outreach" (Text)

   "2nd Outreach" (Text)

customFieldId. List of Number (Integer) -2 items

   28306 (number(integer))

   28306 (number(integer))

a!localVariables(
  local!result: rule!LGH_intCustomFieldsGET(),
  local!rows: if(
    condition: index(local!result, "success", false),
    valueIfTrue: local!result.result.body.values,
    valueIfFalse: {}
  ),
  a!forEach(
    local!rows,
    a!map(
      projectId: index(fv!item, "projectIds", {}),
      name: index(fv!item, "name", {}),
      customFieldId:index(fv!item, "numericId", {})
    )
  )
)

4 replies

stefanhelzle0001
Brainy
Oct 18, 2023 3:54 PM UTC

Having fun with Jira?

a!localVariables(
  local!result: rule!LGH_intCustomFieldsGET(),
  local!rows: if(
    condition: index(local!result, "success", false),
    valueIfTrue: local!result.result.body.values,
    valueIfFalse: {}
  ),
  a!forEach(
    local!rows,
    a!map(
      projectId: {
        index(fv!item, "projectIds", {}),
        index(fv!item, "projectIds", {})
      },
      name: index(fv!item, "name", {}),
      customFieldId: {
        index(fv!item, "numericId", {}),
        index(fv!item, "numericId", {})
      }
    )
  )
)

Inspiring
Oct 18, 2023 4:02 PM UTC

Thanks for your response, can we make it ,dynamic based on the project id.  The second map in the screenshot is showing four project ids.

stefanhelzle0001
Brainy
Oct 18, 2023 4:17 PM UTC

Well, you can create that list using any logic you need.