Remove extra characters while referencing array variable value in azure data factory pipeline.

Rahi Jangle 20 Reputation points
2024-02-27T11:14:58.89+00:00

I have ADF Pipeline which calls SOAP API in copy data as a source in XML format. I need to make some part of that request dynamic. I am generating dynamic xml blocks in for-each using set variable activity having string type variable named "dynamicbody" and append that blocks generated by set variable in each iteration using Append variable activity which stores appended values in array type variable with name "dynamicareablocks". Then I am using another set variable activity which stores these appended blocks in another array variable named "appendedareablocks"

Then I am referencing this array variable in SOAP request body and when request generated it adds some extra characters at the beginning and end of entire variable output as well as before and at end of single array element within output. I want to remove that extra characters from variable output so that I can append original value in soap request. Please help that how to remove same using which activity or expression?

I am putting my second set variable output which I am referring in SOAP:
{ "name": "appendedareablocks", "value": [ "lif2:Area lif2:CodeSetNameEffica/Lifecare</lif2:CodeSetName> lif2:CodeSetId?</lif2:CodeSetId> lif2:CodeValue3201Y</lif2:CodeValue> lif2:CodeDescription?</lif2:CodeDescription> </lif2:Area>", "lif2:Area lif2:CodeSetNameEffica/Lifecare</lif2:CodeSetName> lif2:CodeSetId?</lif2:CodeSetId> lif2:CodeValue3202Y</lif2:CodeValue> lif2:CodeDescription?</lif2:CodeDescription> </lif2:Area>", "lif2:Area lif2:CodeSetNameEffica/Lifecare</lif2:CodeSetName> lif2:CodeSetId?</lif2:CodeSetId> lif2:CodeValue3206Y</lif2:CodeValue> lif2:CodeDescription?</lif2:CodeDescription> </lif2:Area>" ] }

I dont want this square bracket, Curley bracket, double quotes, comma I just want xml nodes only. Please help with the suitable answer.

Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,582 questions
{count} votes

Accepted answer
  1. Amira Bedhiafi 23,251 Reputation points
    2024-02-27T19:08:44.0166667+00:00

    Use the @join() function to concatenate the elements of your array variable into a single string. The @join() function takes two parameters: the array to join and the delimiter to use between each element. In your case, since you want to concatenate XML blocks without any additional characters, you can use an empty string ('') as the delimiter. In a Set Variable activity, you would use an expression similar to the following to transform your appendedareablocks array:

    @join(variables('appendedareablocks'), '')
    
    1 person found this answer helpful.

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.