How to use JSON in delivery directly without JS activity | Community
Skip to main content
November 29, 2023
Solved

How to use JSON in delivery directly without JS activity

  • November 29, 2023
  • 2 replies
  • 1437 views

Hi Team

I have a use case where 
Schema Recipient has a attribute named JsonResponse (example below)


{
"employee": {
"name": "sonoo",
"salary": 56000,
"age": 30
}
}

I want to call employee.name directly within delivery without using JS activity in between, how can I achieve it ?

Solution I tried:

1. Created a workflow with JsonResponse as additional data

2. Inside delivery activity, I have added following

 

<% var test= JSON.parse(targetData.JsonResponse );

%>

Employee Name is : <%= test.employee.name%>

This way I am getting following error

Error while compiling script 'content htmlContent' line 5: #DOMAIN#. SCR-#ID# Javascript&colon; error while evaluating script 'content htmlContent'.

Can someone help with this ?

 

Thanks



This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by KetansingPa1

Hello @ketansingpa1 

It should work the same way for the memo field as well.

 

Could you please share the code you tried?


Hi Manoj
This is resolved, issue was with the memo data type.

Thanks

2 replies

Manoj_Kumar
Community Advisor
Community Advisor
November 29, 2023

Hello @maverick2494 

 

I am assuming the data type of column JsonResponse is astring. If not then use can convert to it a string using toString() function.

 

Then do this:

<% var employee=targetData.JsonResponse.split('"'); var employeeName=employee[5]; %> Employee Name is <%= employeeName %>

 

Manoj  | https://themartech.pro
November 30, 2023

Thanks for looking in to this @_manoj_kumar_ 
The field I am using is of type long text field.
Ex. mEmployee not sEmployee.

I tried above approach getting similar error.
Tried doing toString as well.
It says undefined.

do you think data type long text field can be the reason of failure ?

Thanks

Manoj_Kumar
Community Advisor
Community Advisor
December 5, 2023

Hello @ketansingpa1 

It should work the same way for the memo field as well.

 

Could you please share the code you tried?

Manoj  | https://themartech.pro
Sukrity_Wadhwa
Community Manager
Community Manager
December 15, 2023

Hi @maverick2494,

Were you able to resolve this query or do you still need help here? Do let us know.

Thanks!

Sukrity Wadhwa
December 15, 2023

Hi Sukrity
This is resolved, issue was with the memo data type.

Thanks

Sukrity_Wadhwa
Community Manager
Community Manager
December 15, 2023

Thanks for sharing the update!

Sukrity Wadhwa