Parsing delimited string WebService Connector

Hello,

I am trying to configure create account HTTP operations, below is the exact structure end point requires,

"SecondaryBranches": {

    "item": \[

        {

            "associatedPartyRowid": {

                "rowidObject": "12345"

            }

        },

        {

            "associatedPartyRowid": {

                "rowidObject": "67898"

            }

        }

    \]

}

I am trying to use velocity to dynamically expand the array as there is no limit for this attribute. I also tried to use velocity playground and the output worked on postman.

1. Retrieve the comma-delimited string from the plan arguments

#set($csv = $plan.branchcodes)

2. Process and clean the IDs into an array

#set($ids = $csv.split(“,”))
#set($cleanIds = )
#foreach($v in $ids)
#set($val = $v.toString().trim())
#if($val != “”)
#set($junk = $cleanIds.add($val))
#end
#end

3. Generate the Dynamic JSON Body

#if($cleanIds.size() > 0)
“SecondaryBranches”: {
“item”: [
#foreach($id in $cleanIds)
{
“associatedPartyRowid”: {
“rowidObject”: “$id”
}
}#if($foreach.hasNext),#end
#end
]
}
#end

Issue:

But when the application gets my request, they are reading the exact string instead of value. I have tried using “{$id} still the same. Appreciate any feedback!

“SecondaryBranches”: {

    "item": \[

        {

            "associatedPartyRowid": {

                "rowidObject": "$id"

            }

        },

        {

            "associatedPartyRowid": {

                "rowidObject": "$id"

            }

        }

    \]

}

$id may be reserved, try a different variable, like $branchId

Good point. I tried that as well. Here is my actual JSON Body, error is with rowidObject where its not passing the value to end point. When I use this on developer velocity play ground and use the output on postman, it works fine.

{
“firstName”: “acdfdfd1”,
“lastName”: “ved12”,
“avivaAvantageUserId”: “as_test123”,
“securityRoleName”: {
“roleCode”: “BRKR_EMP_ROLE”
},
“ContactInformation”: {
“item”: [
{
“contactMethodTypeCode”: {
“contactMethodTypeCode”: “BUS_EMAIL”
},
“contactValue”: “adctest@test.ca”
}
]
},##
#set($csv = “12345, 45664”)##
#set($branchids = $csv.split(“,”))##
#set($cleanIds = )##
#foreach($v in $branchids)##
#set($val = $v.toString().trim())##
#if($val != “”)##
#set($junk = $cleanIds.add($val))##
#end##
#end##
#if($cleanIds.size() > 0)
“SecondaryBranches”: {
“item”: [
#foreach($branchid in $cleanIds)
{
“associatedPartyRowid”: {
“rowidObject”: “$branchid”
}
}#if($foreach.hasNext),#end
#end
] #end
},
“brokerageBranchPreferredName”: {
“rowidObject”: “12345”
},
“SuretyPreferences”: {
“suretyIndicator”: {
“indicatorNumberValue”: “0”
}
},
“preferredLanguage”: {
“languageCode”: “EN”
}
}

it looks like you are using Smart Quotes rather than straight quotation marks. I don’t know if this matters or not, but wonder if you replace them with ’ " ', rather than ’ “ ', if it would help… But maybe this is just a difference on keyboard layout …

What if you try changing the “$branchid” to ${branchid}. This might help the Velocity engine know where the variable name begins and ends.

I tried “${branchid} , didn’t work. ${branchid} without quotes throwing error stating not a json object. I am thinking if I should use transform script to convert the incoming comma delimited values and provision it part of create plan .

With the data implying a location, does it make sense that the authoritative source handles them as entitlements in the schema? The ISC Identity attribute is single valued, so a regular transform wouldn’t help, from my perspective.

Good point. unfortuantely we can’t handle them as entitlement eventually switching the static value to identity attribute where we get 10 plus codes dynamically , we should be able to dynamically expand the array. Also attribute sync enabled when there are changes in these codes happen in our authoritative source.

Lots of articles pointing to before operations rule, which we are trying to maintain the environment low code as possible.

I have also raised a ticket to support asking best way to handle, looks like the logic is working dynamically expanding the array, its just not passing the values from the csv. Wonder if that is a limitation on the product itself.

low code is nice in theory, but when you are discussing web services, low or no code isn’t realistic. If you can use the VA web services connector your connector rules aren’t too much of a step up once you get into them.

I made some positive progress. Got the below velocity injected into create static field for the attribute

#set($val = “12345, 78657”) #if($val && $val != “”)#set($arr = $val.split(“,”))#foreach($item in $arr){“associatedPartyRowid”: {“rowidObject”: “$item.trim()”}}#if($foreach.hasNext),#end end-of-life

and called my body using plan

“SecondaryBranches”: {
“item”: [
$plan.Additional Branch Code RowID$
]
},

It went through finally. But I am not able to get the identity attribute in my static velocity code ($val = “identity.attribute”) any idea?

able to get it working using static velocity variable and passing that in my body. Thanks for all your feedback.

#set($val = $identity.getStringAttribute(“identityattributename”))#if($val && $val != “”)#set($arr = $val.split(“,”))#foreach($item in $arr){“associatedPartyRowid”: {“rowidObject”: “$item.trim()”}}#if($foreach.hasNext),#end #end#end