Extra line Appearing in ADF Expression

Asad Amjad 0 Reputation points
2024-08-26T10:57:56.1733333+00:00

I'm using an expression in ADF, but extra lines are appearing in it. Can someone tell me where I'm going wrong? and I m new here so please help me out

And the expression (Data Flow) I am using is this:

@( 
    @(
    address = @(
        countryCode = Country
    ),
    contactPointType = '1',
    lastUpdated = @(
        updatedAt = '1900-01-01T00:00:00.000',
        updatedBy = 'EPLOY'
    ),
    sortOrder = 0
),
@(
    additionalContactInfo = @(
        eMail = Email,
        eMailCc = iif(isNull(Email2) || Email2 == '', '', Email2)
    ),
    address = @(
        countryCode = Country,
        place = Town,
        postcode = PostCode,
        province = County,
        streetAddress = Address11
    ),
    contactPointType = '9',
    lastUpdated = @(
        updatedAt = '1900-01-01T00:00:00.000',
        updatedBy = 'EPLOY'
    ),
    phoneNumbers = @(
        telephone1 = Telephone11,
        telephone4 = telephone41
    ),
    sortOrder = 0
)
)

This is the output coming

"contactPoints":[{"@(\n    address = @(\n    countryCode = SelectedCandidateColumns@Country),\n    contactPointType = '1',\n    lastUpdated = @(\n    updatedAt = '1900-01-01T00:00:00.000',\n    updatedBy = 'EPLOY'),\n    sortOrder = 0)":
{"address":{"countryCode":"GB"},"contactPointType":"1","lastUpdated":{"updatedAt":"1900-01-01T00:00:00.000","updatedBy":"EPLOY"},"sortOrder":0},
"@(\n    additionalContactInfo = @(\n    eMail = SelectedCandidateColumns@Email,\n    eMailCc = iif(isNull(SelectedCandidateColumns@Email2) || SelectedCandidateColumns@Email2 == '', '', SelectedCandidateColumns@Email2)),\n    address = @(\n    countryCode = SelectedCandidateColumns@Country,\n    place = SelectedCandidateColumns@Town,\n    postcode = SelectedCandidateColumns@PostCode,\n    province = SelectedCandidateColumns@County,\n    streetAddress = derivedColumn3@Address11),\n    contactPointType = '9',\n    lastUpdated = @(\n    updatedAt = '1900-01-01T00:00:00.000',\n    updatedBy = 'EPLOY'),\n    phoneNumbers = @(\n    telephone1 = derivedColumn3@Telephone11,\n    telephone4 = derivedColumn3@telephone41),\n    sortOrder = 0)":


{"additionalContactInfo":{"eMail":"weaponx@eagles.com","eMailCc":""},"address":{"countryCode":"GB","place":"Sevenoaks","postcode":"TN132PZ","province":"Kent","streetAddress":"Novacare Complex"},"contactPointType":"9","lastUpdated":{"updatedAt":"1900-01-01T00:00:00.000","updatedBy":"EPLOY"},"phoneNumbers":{"telephone1":"+441732451530","telephone4":"+447123456789"},"sortOrder":0}}]

How to get these line out from my output

 {"@(\n    address = @(\n    countryCode = SelectedCandidateColumns@Country),\n    contactPointType = '1',\n    lastUpdated = @(\n    updatedAt = '1900-01-01T00:00:00.000',\n    updatedBy = 'EPLOY'),\n    sortOrder = 0)"


"@(\n    additionalContactInfo = @(\n    eMail = SelectedCandidateColumns@Email,\n    eMailCc = iif(isNull(SelectedCandidateColumns@Email2) || SelectedCandidateColumns@Email2 == '', '', SelectedCandidateColumns@Email2)),\n    address = @(\n    countryCode = SelectedCandidateColumns@Country,\n    place = SelectedCandidateColumns@Town,\n    postcode = SelectedCandidateColumns@PostCode,\n    province = SelectedCandidateColumns@County,\n    streetAddress = derivedColumn3@Address11),\n    contactPointType = '9',\n    lastUpdated = @(\n    updatedAt = '1900-01-01T00:00:00.000',\n    updatedBy = 'EPLOY'),\n    phoneNumbers = @(\n    telephone1 = derivedColumn3@Telephone11,\n    telephone4 = derivedColumn3@telephone41),\n    sortOrder = 0)
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
10,593 questions
{count} votes

3 answers

Sort by: Most helpful
  1. Amira Bedhiafi 23,251 Reputation points
    2024-08-26T12:04:00.13+00:00

    Try to flatten your expression by eliminating unnecessary nested structures if possible :

    @(
       {
         "contactPoints": [
           {
             "address": {
               "countryCode": Country
             },
             "contactPointType": "1",
             "lastUpdated": {
               "updatedAt": "1900-01-01T00:00:00.000",
               "updatedBy": "EPLOY"
             },
             "sortOrder": 0
           },
           {
             "additionalContactInfo": {
               "eMail": Email,
               "eMailCc": iif(isNull(Email2) || Email2 == '', '', Email2)
             },
             "address": {
               "countryCode": Country,
               "place": Town,
               "postcode": PostCode,
               "province": County,
               "streetAddress": Address11
             },
             "contactPointType": "9",
             "lastUpdated": {
               "updatedAt": "1900-01-01T00:00:00.000",
               "updatedBy": "EPLOY"
             },
             "phoneNumbers": {
               "telephone1": Telephone11,
               "telephone4": telephone41
             },
             "sortOrder": 0
           }
         ]
       }
    )
    
    
    0 comments No comments

  2. Asad Amjad 0 Reputation points
    2024-08-26T12:23:38.7566667+00:00

    Thanks for your reply, but I am trying to create a column in the desired column. 'Activity' and 'ContactPoints' are already column names. If I use 'ContactPoint' again, it gives me the column twice.

    This is the original JSON file which I need to build with the same structure in ADF.

    "contactPoints": [ 

        { 

          "address": { 

            "countryCode": "GB" 

          }, 

          "contactPointType": "1", 

          "lastUpdated": { 

            "updatedAt": "1900-01-01T00:00:00.000", 

            "updatedBy": "EPLOY" 

          }, 

          "sortOrder": 0 

        }, 

            { 

          "additionalContactInfo": { 

            "eMail": "shady25@eagles.com", 

            "eMailCc": "" 

          }, 

          "address": { 

            "countryCode": "GB", 

            "place": "London", 

            "postcode": "N17 0BX", 

            "province": "", 

            "streetAddress": "782, High Road" 

          }, 

          "contactPointType": "9", 

          "lastUpdated": { 

            "updatedAt": "1900-01-01T00:00:00.000", 

            "updatedBy": "EPLOY" 

          }, 

          "phoneNumbers": { 

            "telephone1": "+4420801234567", 

            "telephone4": "+447777777777" 

          }, 

          "sortOrder": 0 

        } 

        ]

    0 comments No comments

  3. phemanth 10,250 Reputation points Microsoft Vendor
    2024-08-27T12:39:34.8766667+00:00

    @Asad Amjad

    Thanks for using MS Q&A platform and posting your query.

    I understand that you're experiencing issues with extra lines appearing in your Azure Data Factory (ADF) expression output.

    To remove the extra lines and expression syntax, you can use the toString() function in ADF. This function will help you convert the expression output to a string, removing any unnecessary characters.

    Here's an updated version of your expression:

    toString(
        @(
            address = @(
                countryCode = Country
            ),
            contactPointType = '1',
            lastUpdated = @(
                updatedAt = '1900-01-01T00:00:00.000',
                updatedBy = 'EPLOY'
            ),
            sortOrder = 0
        ),
        @(
            additionalContactInfo = @(
                eMail = Email,
                eMailCc = iif(isNull(Email2) || Email2 == '', '', Email2)
            ),
            address = @(
                countryCode = Country,
                place = Town,
                postcode = PostCode,
                province = County,
                streetAddress = Address11
            ),
            contactPointType = '9',
            lastUpdated = @(
                updatedAt = '1900-01-01T00:00:00.000',
                updatedBy = 'EPLOY'
            ),
            phoneNumbers = @(
                telephone1 = Telephone11,
                telephone4 = telephone41
            ),
            sortOrder = 0
        )
    )
    

    Expected Output

    By using the toString() function, your output should now look like this:

    [
        {
            "address": {
                "countryCode": "GB"
            },
            "contactPointType": "1",
            "lastUpdated": {
                "updatedAt": "1900-01-01T00:00:00.000",
                "updatedBy": "EPLOY"
            },
            "sortOrder": 0
        },
        {
            "additionalContactInfo": {
                "eMail": "weaponx@eagles.com",
                "eMailCc": ""
            },
            "address": {
                "countryCode": "GB",
                "place": "Sevenoaks",
                "postcode": "TN132PZ",
                "province": "Kent",
                "streetAddress": "Novacare Complex"
            },
            "contactPointType": "9",
            "lastUpdated": {
                "updatedAt": "1900-01-01T00:00:00.000",
                "updatedBy": "EPLOY"
            },
            "phoneNumbers": {
                "telephone1": "+441732451530",
                "telephone4": "+447123456789"
            },
            "sortOrder": 0
        }
    ]
    

    Hope this helps. Do let us know if you any further queries.

    0 comments No comments

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.