Legacy Dev Forum Posts

 View Only

Sign Up

SuccessTemplate - Concatenate variables

  • 1.  SuccessTemplate - Concatenate variables

    Posted 06-05-2025 18:43

    JBambi | 2022-09-21 14:34:29 UTC | #1

    Hello,

    I'm trying to concatenate 2 variables in order to create an email address but I'm having difficulties because of the quotes:

    Here is my successTemplate:

    "successTemplate": "#set($a = $localpart) #set($b = $domain) #set($c = $a.concat(\"@\").concat($b)) {\"email\": $c}" }

    And the error I got:

    { "message": "Transform failed to process result using 'successTemplate' template due to error:'Unexpected character ('@' (code 64)): was expecting comma to separate Object entries\n at [Source: (String)\" {\"email\": \"test\"@\"example.com\"}\"; line: 1, column: 18]'\n Template:'#set($a = $localpart) #set($b = $domain) #set($c = $a.concat(\"@\").concat($b)) {\"email\": $c}'.", "code": "bad.request", "status": 400, "messageParams": {}, "contextId": "27cd2052-98e9-4e48-8487-6b09215ad375", "details": [ { "errorCode": "ACTION.PROCESSING" } ], "errors": [] }

    I tried to use $esc.quote in different places but with no success. Can anyone help me to build the response ?

    Thanks, Joan


    Hampus_Nygren | 2022-09-26 07:17:12 UTC | #2

    Hi,

    What if you do: "successTemplate": "#set($a = $localpart.replace($esc.q, \\"\\")) #set($b = $domain.replace($esc.q, \\"\\")) #set($c = $a.concat(\\"@\\").concat($b)) {\\"email\\": \\"$c\\"}"


    JBambi | 2022-09-26 07:17:04 UTC | #3

    Hi,

    Thanks, It was what I was looking for. Those quotes are real headaches.


    system | 2022-10-27 07:18:01 UTC | #4

    This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.


    This post was migrated from the old Developer Forum.

    ref: 16379