Share via


Logic Apps not adding new line

Question

Thursday, May 9, 2019 3:06 AM

Hi,

I've set up a Logic Apps process using an HTTP request trigger which received a JSON file (grouped together using an array).  

{

"properties": {

"RetailerJobInfo": {

"items": {

"properties": {

"City": {

"type": "string"

},

"CoC_CoV_Certificate": {

"type": "string"

},

"ContactNumber": {

"type": "string"

},

"ContactPerson": {

"type": "string"

},

"CustomerReference": {

"type": "string"

},

"DueDate": {

"type": "string"

},

"ICP": {

"type": "string"

},

"JobNotes": {

"type": "string"

},

"LastMeterReading": {

"type": "string"

},

"MeterLocation": {

"type": "string"

},

"MeterSerial": {

"type": "string"

},

"MeterType": {

"type": "string"

},

"RequestedWorkType": {

"type": "string"

},

"Retailer": {

"type": "string"

},

"StreetName": {

"type": "string"

},

"StreetNumber": {

"type": "string"

},

"Suburb": {

"type": "string"

}

},

"required": [

"Retailer",

"CustomerReference",

"DueDate",

"RequestedWorkType",

"StreetNumber",

"StreetName",

"Suburb",

"City",

"ICP",

"MeterSerial",

"MeterType",

"MeterLocation",

"LastMeterReading",

"ContactPerson",

"ContactNumber",

"JobNotes"

],

"type": "object"

},

"type": "array"

}

},

"type": "object"

}

Logic Apps then emails the values in an email (using a For Each on the array)

{

"inputs": {

"host": {

"connection": {

"name": "@parameters('$connections')['office365_1']['connectionId']"

}

},

"method": "post",

"body": {

"Body": "Customer Ref:@{items('For_each')?['CustomerReference']} \nRequested Work Type:@{items('For_each')?['RequestedWorkType']} \nAddress:@{items('For_each')?['StreetNumber']} @{items('For_each')?['StreetName']}, @{items('For_each')?['Suburb']}, @{items('For_each')?['City']}\nICP:@{items('For_each')?['ICP']}\nRetailer:@{items('For_each')?['Retailer']}\nMeter Serial #:@{items('For_each')?['MeterSerial']} \nMeter Type:@{items('For_each')?['MeterType']} \nMeter Location:@{items('For_each')?['MeterLocation']} \nLast Meter Reading:@{items('For_each')?['LastMeterReading']} \nContact Person:@{items('For_each')?['ContactPerson']}\nContact Number:@{items('For_each')?['ContactNumber']} \nJob Notes:@{items('For_each')?['JobNotes']} \nDue Date:@{items('For_each')?['DueDate']} \nCoC or CoV Required:@{items('For_each')?['CoC_CoV_Certificate']}",

"Subject": "Test",

"To": "hidden"

},

"path": "/Mail",

"authentication": "@parameters('$authentication')"

}

}

I've added a \n after each item in the email body, but for some reason after the "City" value a new line isn't added. Any ideas how I could fix this please? Thanks. 

All replies (3)

Thursday, May 9, 2019 4:28 AM

I would suggest you to make use of design and expression window to write this big expression but not only the code view. The chances are there might be some character here and there causing the problem. Please have a look on this screenshot of how i do it:

So when i press 'enter' of my keyboard while writing the body, it automatically put new line in the code view hence i dont have to worry about looking into that big expression. this view gives the idea about how the body is gonna look like in the end. Cheers. 

Thanks Sovit


Thursday, May 9, 2019 5:47 AM

Thanks a lot for your help! it worked!

Cheers


Monday, May 27, 2019 10:14 PM

Hi,

Just an update on this thread.  The problem has reappeared.  It looks like when the Street Number, Street Name and City have more than a certain amount of characters the ICP field (below city) then joins the same line as city.  I have built the whole thing in the design and expression window.  In the code there is a /n displaying too after each field.  Is there a character limit before it ignores the /n command?

Any help would be much appreciated.

Thanks.