Pattern Designer -> How to process a multi value field and write that into a CMDB field as a String?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
This a "Pattern Designer" question.
This JSON is pulled via API into the Pattern, I'm just showing here one record:
{
"name": "aaa-cr-network-it.hub-bbbb-001-vnt",
"id": "/subscriptions/111111111-e23d-4322-8b22-056c83022222/resourceGroups/aaa-pr-network-ithub-bbbb-001-rgp/providers/Microsoft.Network/virtualNetworks/aaaa-pr-network-it.hub-bbbb-001-vnt",
"properties": {
"provisioningState": "Succeeded",
"dhcpOptions": {
"dnsServers": ["10.33.24.11", "10.11.24.12", "10.22.24.13"]
}
}
}
I need to put that "dnsServers" value into a string field in CMDB: "cmdb_ci_network . u_azure_dns_server"
ISSUE: see attached screenshot, the "dnsServers" is recognised by the Pattern "Highlighter tool" as separate values.
I need an EVAL() script or other solution to merge them into a Comma Separated String, so I can Write that into the CMDB field!
Any idea? 😀 No AI slop, or no "rank-pumping" nonsense answer please.
Just real ideas, if I may ask.
.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
3 weeks ago - last edited 3 weeks ago
Hi,
Use the pattern designer json parser to parse dnsServers array as is, as a string ,into a standard $dns_string variable
Then create another set parameter value step with the following JS Eval statement to convert it into a newline-separated string:
var rawStr = ${dns_string};
var cleanStr = rawStr.replace(/[\[\]"\s]/g, "");
var rtrn = cleanStr.split(",").join("\n");
rtrn;
Then create Parse Variable step to parse it into a standard table(or csv value string) using new line delimiter option.
Please let us know if it helps.
