mgonzato Valued Contributor.
Valued Contributor.
217 views

CIT Create multiple record from one

Jump to solution

Greetings, I'm strunggling with a mapping on Connect-it.

I read and write from AM, but I'm not able to create multiple records starting from one entry. I have a list of IP addresses and I need to create a single record for each one of them. The image shows that NetworkCards recive only one record.

How can i do this? I did not found any usefull function in the documentation, i tryed with pifsetstringval but I'm not sure it is the right way to do it. I suppose the code has to be placed in the NetworkCards Mapping box. 

Thanks in advance for the help

0 Likes
1 Solution

Accepted Solutions
mgonzato Valued Contributor.
Valued Contributor.

Re: CIT Create multiple record from one

Jump to solution

I managed to make it work using my first idea. Thanks to everybody who replied and helped me out.

The file provided by egregoire didn't work as I expected, as it put all the IPs on a single record on amNetworkCards.

Here is the screens of the final work

Mapping:

Schermata 2019-06-13 alle 17.46.05.png

View data preview:

Schermata 2019-06-13 alle 17.46.46.png

 

As you can see it creates multiple istances of NetworkCards, based on the number of IP adresses associated with the amComputer element.

The elements used as a key are still a work in progress, but the main operation is done.

The code I used is the follow:

Dim lErr as Long
if [ipv4Address] = "None" then
lErr = PifIgnoreDocumentMapping("The " + [hostName] + " elemnt has no IP associated")
else
Dim ips as String
Dim iterator as Long
iterator = 0
'clear the ip list 
ips = Replace(Replace(Replace([ipv4Address], "[", "", 0), "]", "", 0), "'", "", 0)
  while iterator < (CountOccurences(ips, ",", "]") + 1 ) and iterator < 100
  lErr = PifSetStringVal("NetworkCards(" & iterator & ").TcpIpAddress", GetListItem(ips, ",", (iterator+1), "]"))
  lErr = PifSetStringVal("NetworkCards(" & iterator & ").Description", [hostName])
  iterator = iterator + 1
  wend
end if

 

Thanks to everybody

6 Replies
Acclaimed Contributor.. Mark Cullen_1 Acclaimed Contributor..
Acclaimed Contributor..

Re: CIT Create multiple record from one

Jump to solution

Based on screenshot, network cards is a collection mapping in that each network card gets branched to NetworkCards (0), NetworkCards (1),...NetworkCards (n).  If you really want to create a single record for each of them, then starting from amNetworkCard table as root and branching to Computer will help.

0 Likes
Trusted Contributor.. egregoire Trusted Contributor..
Trusted Contributor..

Re: CIT Create multiple record from one

Jump to solution

Hi mgonzato,

when I see your screenshot, I see a collection (networkCards) with a unique member/element.

I would like to know where your screenshot is coming, from the AM source connector or from the result of your mapping box?

I have another way of helping you:
From a copy of your CIT scenario, remove ALL information regarding connection, user login an user password, rename it with txt extension and it put it in an attachment to your next post.

I want to see your code, because usually when you map a collection, CIT will create automatically one record by member/element of your source collection.

In addition, you can't map a structured source node as a destination collection.

 

BR

EG

0 Likes
mgonzato Valued Contributor.
Valued Contributor.

Re: CIT Create multiple record from one

Jump to solution

Thank you.

As Mark Cullen_1 suggestet I mapped the data to amNetworkCard, and used amComputer as extenal key.

What happens here is that TcpIpHostName is a key. For each one the mapping try to create (or update if it exist, not implemented yet), n new amNetworkCard (description + IP address).

The last screenshot comes from the mapping editing, you right click on the destination and select "view the data produced for the mapping" and it shows you a simulation of the mapping.

I compressed the scenario in a .zip file. Nor txt nor scn are valid extensions in this forum

0 Likes
Trusted Contributor.. egregoire Trusted Contributor..
Trusted Contributor..

Re: CIT Create multiple record from one

Jump to solution

I have seen Mark Cullen_1's replay, the solution is correct.

I have seen your scenario, you have made two mistakes:

1) You can't mixte a root code data manipulation with a single field code (drag and drop).

2) Your both scenarios will never work because your Scenario approach is wrong.

I will send you a scenario working with your specifications (found in your scenario)

BR

EG

0 Likes
Trusted Contributor.. egregoire Trusted Contributor..
Trusted Contributor..

Re: CIT Create multiple record from one

Jump to solution

mgonzato,

You will find a scenario working without AM structure changing. 

How does this script work?

For each record in the source, we find if we have a record created before (based on a couple of fields [Description]+[Computer.TcpIpHostName]

-Maybe you will have better results if you are using [Computer.Name] (data consistency)-)

If we find a record in DB (amNetworkCards) we update it. If not, we create it

To be honest, Because my DB doesn't have your table, I didn't test this scenario.

You have to pay attention to the reconciliation keys (little red keys on fields).

If you have any trouble when you try to insert or update records it's perhaps the keys are the root cause (try ).

You can evaluate this scenario in the test mode before to run it in dev/test.

Don't worry if you see in "view the data produced for the mapping" only one by one record.

This is the way this script works, but in the end, you will see what you expect.

BR

EG

0 Likes
mgonzato Valued Contributor.
Valued Contributor.

Re: CIT Create multiple record from one

Jump to solution

I managed to make it work using my first idea. Thanks to everybody who replied and helped me out.

The file provided by egregoire didn't work as I expected, as it put all the IPs on a single record on amNetworkCards.

Here is the screens of the final work

Mapping:

Schermata 2019-06-13 alle 17.46.05.png

View data preview:

Schermata 2019-06-13 alle 17.46.46.png

 

As you can see it creates multiple istances of NetworkCards, based on the number of IP adresses associated with the amComputer element.

The elements used as a key are still a work in progress, but the main operation is done.

The code I used is the follow:

Dim lErr as Long
if [ipv4Address] = "None" then
lErr = PifIgnoreDocumentMapping("The " + [hostName] + " elemnt has no IP associated")
else
Dim ips as String
Dim iterator as Long
iterator = 0
'clear the ip list 
ips = Replace(Replace(Replace([ipv4Address], "[", "", 0), "]", "", 0), "'", "", 0)
  while iterator < (CountOccurences(ips, ",", "]") + 1 ) and iterator < 100
  lErr = PifSetStringVal("NetworkCards(" & iterator & ").TcpIpAddress", GetListItem(ips, ",", (iterator+1), "]"))
  lErr = PifSetStringVal("NetworkCards(" & iterator & ").Description", [hostName])
  iterator = iterator + 1
  wend
end if

 

Thanks to everybody

The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.