Skip to content

Commit

Permalink
SALTO-7097: add more references to json body (#6975)
Browse files Browse the repository at this point in the history
  • Loading branch information
edenhassid authored Dec 19, 2024
1 parent 0bb4942 commit 769c1c6
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -406,12 +406,7 @@ const replaceFormulasWithTemplates = ({
if (!_.isString(value)) {
return value
}
try {
// Checks if this is a JSON string
JSON.parse(value)
} catch {
return value
}
// we assume that the value that will be caught here is a json with zendesk placeholders
return extractTemplate(value, [ID_KEY_IN_JSON_REGEX], expression => {
if (!ID_KEY_IN_JSON_REGEX.test(expression)) {
return expression
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ describe('handle templates filter', () => {
['dcno', '{{dc.not_exists}}'],
[
'testJson',
`{\n\t"ticket": {\n\t\t"custom_fields": [\n\t\t\t{\n\t\t\t\t"id": ${placeholder3.value.id},\n\t\t\t\t"testdc": "${dynamicContentRecord.value.placeholder}"\n\t\t\t}\n\t\t],\n\t\t"id": ${placeholder2.value.id}\n\t},\n\t"id": "${placeholder3.value.id}"\n}\n`,
`{\n\t"ticket": {\n\t\t"custom_fields": [\n\t\t\t{\n\t\t\t\t"id": ${placeholder3.value.id},\n\t\t\t\t"testdc": "${dynamicContentRecord.value.placeholder}"\n\t\t\t}\n\t\t],\n\t\t"id": ${placeholder2.value.id}, "value": {{ sum_total }}\n\t},\n\t"id": "${placeholder3.value.id}"\n}\n`,
],
],
},
Expand Down Expand Up @@ -498,7 +498,7 @@ describe('handle templates filter', () => {
parts: [
`{\n\t"ticket": {\n\t\t"custom_fields": [\n\t\t\t{\n\t\t\t\t"id": ${placeholder3.value.id},\n\t\t\t\t"testdc": "{{`,
new ReferenceExpression(dynamicContentRecord.elemID, dynamicContentRecord),
`}}"\n\t\t\t}\n\t\t],\n\t\t"id": ${placeholder2.value.id}\n\t},\n\t"id": "${placeholder3.value.id}"\n}\n`,
`}}"\n\t\t\t}\n\t\t],\n\t\t"id": ${placeholder2.value.id}, "value": {{ sum_total }}\n\t},\n\t"id": "${placeholder3.value.id}"\n}\n`,
],
}),
],
Expand Down Expand Up @@ -796,7 +796,7 @@ describe('handle templates filter', () => {
new ReferenceExpression(dynamicContentRecord.elemID, dynamicContentRecord),
'}}"\n\t\t\t}\n\t\t],\n\t\t"id": ',
new ReferenceExpression(placeholder2.elemID, placeholder2),
'\n\t},\n\t"id": "',
', "value": {{ sum_total }}\n\t},\n\t"id": "',
new ReferenceExpression(placeholder3.elemID, placeholder3),
'"\n}\n',
],
Expand Down

0 comments on commit 769c1c6

Please sign in to comment.