Expand my Community achievements bar.

SOLVED

How to use JSON in delivery directly without JS activity

Avatar

Level 1

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



Topics

Topics help categorize Community content and increase your ability to discover relevant content.

1 Accepted Solution

Avatar

Correct answer by
Level 1

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

Thanks

View solution in original post

7 Replies

Avatar

Community Advisor

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
     Find me on LinkedIn

Avatar

Level 1

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

Avatar

Community Advisor

Hello @ketananxi123 

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

 

Could you please share the code you tried?


     Manoj
     Find me on LinkedIn

Avatar

Correct answer by
Level 1

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

Thanks

Avatar

Administrator

Hi @Maverick2494,

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

Thanks!



Sukrity Wadhwa

Avatar

Level 1

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

Thanks

Avatar

Administrator

Thanks for sharing the update!



Sukrity Wadhwa