Indexing the values is returned as an array value"[]", but it is a single value

Certified Associate Developer

I am trying to return some values in a web API of mine where I call an expression rule that maps the vales that are wanted. The thin is I used index() function to cast the values like this 

childId: rule!A_QE(index(fv!item, "id", null()))['recordType!{record}Record.fields.{record}.childId'],

where the item is going through an iterative loop to fetch each list.

in the web API it is getting returned as: 

"childId" : [ 777 ],

which i do not want it in this form i need it to be returned in the following form:

"childId" : 777 ,

I tried to add at the end of the index, [1] and it is still returning the same form..

  Discussion posts and replies are publicly visible

Parents
  • +1
    Certified Lead Developer

    Hi,
    Instead of adding [1] at the end of the index, index the value from the rule result. Refer to the below snippet.

    childId: index(
          /*calling rule*/rule!AA_QR_getVehicleStatus(
            refStatusId: index(local!status, "id", null())
          )['recordType!{c40f19ec-824f-4377-8d6f-60c072fa9721}AA Vehicle Status.fields.{c84004ba-e283-4b93-90d8-b6faf7561625}sortOrder'],
          1,
          null()
        )

Reply
  • +1
    Certified Lead Developer

    Hi,
    Instead of adding [1] at the end of the index, index the value from the rule result. Refer to the below snippet.

    childId: index(
          /*calling rule*/rule!AA_QR_getVehicleStatus(
            refStatusId: index(local!status, "id", null())
          )['recordType!{c40f19ec-824f-4377-8d6f-60c072fa9721}AA Vehicle Status.fields.{c84004ba-e283-4b93-90d8-b6faf7561625}sortOrder'],
          1,
          null()
        )

Children