Skip to main content
ladislavm0002
December 1, 2022
Question

How to extend array with attributes

  • December 1, 2022
  • 2 replies
  • 0 views

Hello guys, in my database ICH_Contracts i have information about my master contract saved in several attributes. In my process model this is saved as a porcess variable:

contracts = [startYear=2023, startMonth=1, noOfOccurences=5, isCancelled=N, frequency=FRQ1, active=Y, createdOn=12/1/2022 4:15 PM, createdBy=jmaricl@jci.com, lastUpdateDate=12/1/2022 4:16 PM, lastUpdateBy=jlopeza7, contractType=CTYPE2, contractId=175, contractNumber=FY2300000176]

I have a process variable which stores information about the child contract numbers:

childcontractsnumber = FY2300000176_1; FY2300000176_2; FY2300000176_3; FY2300000176_4; FY2300000176_5

What i need to achieve is to add these child contract numbers to the contracts DB as new rows, where the contractNumber will be the values from pv!childcontractsnumber and the rest of the attributes will be just copied. So basically extend the contracts pv with these 5 new values.

Can you please help me out with this?

THanks

2 replies

alexandru.boerescu
December 1, 2022

Write something like this in a Script task, save the result in an output parameter and feed it in a Write Records/Write to Data Store

a!localVariables(
  local!childcontractsnumber: {
    "FY2300000176_1",
    "FY2300000176_2",
    "FY2300000176_3",
    "FY2300000176_4",
    "FY2300000176_5"
  },
  local!contract: {{
    startYear: 2023,
    startMonth: 1,
    noOfOccurences: 5,
    contractNumber: "FY2300000176"}
  },
  local!extendedChildContractsList: a!forEach(
    items: local!childcontractsnumber,
    expression: {
      {
        contractNumber: fv!item,
        startYear: local!contract[1].startYear,
        startMonth: local!contract[1].startMonth,
        noOfOccurences: local!contract[1].noOfOccurences
      }
    }
  ),
  append(local!contract,local!extendedChildContractsList)
)

ladislavm0002
December 2, 2022

thanks, it worked out