how to pass array in expression rule

I



I want the result of this expression rule to be in the below format or the highlighted format in the editor. currently I am passing name and comment from one CDT ,now along with this 2 fields  I need to pass the colleagues array with add array with in the colleague array.


I have created other new  CDT for colleague array with id , typeid and addcolleague array in it ,how to call it in the expression rule to get the result in the below format . Please advise



How can I get this result in the below format ,can someone please advise


Expected RESULT

a!toJson

({

"name": "string",
"Comment": "string",

Colleagues:
{

{

"TypeId": 1,
addColleague:

{
"email": "string",
"displayName": "String",
"eFlag": false,
"dFlag": false,
"ProviderID": 2,
"idFromProvider": "string"   }

}

}


})

  Discussion posts and replies are publicly visible

Parents Reply Children
  • a!toJson(
    {
    name: "NAME",
    Comment: "comments",
    CAC: {
    a!map(
    TypeId: 1,
    addcolleague: a!map(
    email: "requestorEmail",
    displayname:"requestorName",

    deletedFlag: false,
    identityProviderID: 2,
    idFromProvider:"Value"

    )

    )
    }
    }
    )


    I'm getting output as 


    "{"name":"NAME",
      Comment":"comments",

    "CAC:
    [

    {"TypeId":1,
    "addcolleague":{"email":"requestorEmail",
    "displayname":"requestorName",
    deletedFlag":false,
    "identityProviderID":2,

    "idFromProvider":"sagdoi"

    }}

    ]

    }"


     :Instead  of [ ] , I need  { } ,can you please help ,rest everything is expected.


    I'm passing this expressinrule output as an input to integration ,it says [ ] is invalid. can you please help

  • Instead  of [ ] , I need  { }

    The [ ] here are because the structure of your code indicates that the "CAC" property will contain an array, since you use curly brackets and then a!map().  If it's just supposed to contain a single sub-dictionary then you don't need to double-indicate this - meaning you could just pass in an a!map() call, OR the curly brackets - when you use both, it assumes that the property contains an array of (one of) that map.

    This is what I get when I comment out just one of those: