General Discussion

 View Only
  • 1.  DREL New line?

    Adopter
    Posted 10-17-2022 15:30
    Hi everyone! I was wondering if anyone has knowledge on how to create a new line (enter) in a DREL document? I keep thinking this should be super simple but everything I have tried hasn't worked. Here is my situation: We use the DREL document to create a chatter message in Salesforce on the Work Order record. In the example below, the chatter message will say the totals of the dispensers, plus total rooms. I would like to separate Campus Total Dispensers and Total Rooms onto a new line for ease of viewing. Right now, the post looks like this:

    "End User Site Assessment Complete: Soap: 10. Sanitizer: 15. Lotion: 0. Shower: 0. Campus Dispenser Total: 0. Total Rooms: 0."

    I would like the chatter post to look like this instead:

    "End User Site Assessment Complete:
    Soap: 10. Sanitizer: 15. Lotion: 0. Shower: 0.
    Campus Dispenser Total: 0.
    Total Rooms: 0."

    Any ideas? I have tried \n with no success.


    Thanks!

    ------------------------------
    Lisa Zido
    Technical Systems Analyst
    GOJO Industries Inc.
    OH
    ------------------------------


  • 2.  RE: DREL New line?

    Staff
    Posted 10-17-2022 17:40

    Hi Lisa, I believe you just need to escape the new line character, which you can do by including the following property: [#escapeDocumentFormat] where DocumentFormat is either Json, Xml, Html, Csv or Url.

    So for what you provided there you would want your DREL Template to look like this

    #c[escapeJson]
    {
        "body": {
            "message": [{
                "type": "Text",
                "text": "Site Assessment Complete\nSoap: %a[C_SoapTotal].\nSanitizer: %a[C_SanitizerTotal]...etc"
            }]
        },
    }

    I obviously didn't put the line breaks in my example in the same spot as what you were asking for in your formatting, nor did I type out your full text string, but I think you get the idea.

    The full documentation on how to escape special characters in DREL is in our product documentation, which you can find here: https://docs.prontoforms.com/1374411/Content/IntegrateWithOtherSystems/EscapeDRELFreemarkerHandlebarsOutput.htm?Highlight=escape%20characters



    ------------------------------
    Pat Cooney
    Community Engineer
    ProntoForms
    community@prontoforms.com
    ------------------------------



  • 3.  RE: DREL New line?
    Best Answer

    Adopter
    Posted 10-18-2022 12:23
    Thanks Pat!! I think in the past I was trying to use escape json and \n in different places than where you put them in your example, and so I never got it to work! I did exactly as you did and that finally worked for me! I'm excited! Time to go rearrange my DREL documents... :)

    DREL test:
    #c[escapeJson]
    { 
       "body" : {
          "messageSegments" : [
             {
                "type" : "Text",
                "text" : "Site Assessment complete\nFirst Line: %a[chatter 1]. \nSecond Line: %a[chatter 2].\nThird Line: %a[chatter 3]"
             }]
           },
       "feedElementType" : "FeedItem",
       "subjectId" : "%a[IdWorkOrder]"
    }

    Chatter post:


    ------------------------------
    Lisa Zido
    Technical Systems Analyst
    GOJO Industries Inc.
    OH
    ------------------------------



  • 4.  RE: DREL New line?

    Staff
    Posted 10-18-2022 14:33
    Awesome! Glad it worked out!

    ------------------------------
    Pat Cooney
    Community Engineer
    ProntoForms
    community@prontoforms.com
    ------------------------------



Reminder: Content posted to our Community is public content.  Please be careful not to post Intellectual Property that you do not have permission to share.  For more information please refer to our Terms Of Use