โ08-06-2021 03:29 AM
Hi
The json input I get to the pipeline is array of objects. I need iterate each object data and join as a string.
Also I need to append some html code in between.
Ex: input json
โchathistโ: [{
โcreated_byโ: โtestโ,
โcreated_dateโ: 1626244986151,
โinformation_typeโ: โRequestโ,
โtextโ: "Account ",
โcontentโ: โโ,
โcontent_typeโ: โQuestionโ
}, {
โcreated_byโ: โWsswWโ,
โcreated_dateโ: 1626244990226,
โinformation_typeโ: โResponseโ,
โtextโ: "Clicca sulla Societร alla quale ",
โcontentโ: โโ,
โcontent_typeโ: โtextโ
}, {
โcreated_byโ: โtestโ,
โcreated_dateโ: 1626244998853,
โinformation_typeโ: โRequestโ,
โtextโ: โexample test456โ,
โcontentโ: โโ,
โcontent_typeโ: โsrnโ
}
]
This input array of objects need to parse and join as string. First I need to check array length > 0
I have similar logic using JSonata. I am trying to achieve this using Expression builder.
{{ $count($Request.Hist ) > 0 ?
$join( [ โ[code]
Can we use JSonata in Snaplogicโฆ ? if not how we can achieve this through expression builder. I tried few ways using Array and String function but did not resolve.
Pls suggest.
thanks
arun
โ08-06-2021 04:05 AM
Hi @arunnp,
Check if this is the correct format according to your requirement:
If it is, use the following expression in a mapper:
$chathist.length > 0 ? $chathist.map(x=>x.toString().replaceAll(โ,โ,โ&โ).replace(/{|}/gi,โโ)) : $chathist
โ08-06-2021 05:01 AM
Hi @bojanvelevski Thanks for reply.
I am not looking for concatenating the fields as string. The requirement is go through each object in the array appending the โtextโ field value inside the โcontentโ object.
Below is the sample jsonata expression for this
the sample array is like this
โchathistโ: [{
โcreated_byโ: โTestโ,
โtextโ: โAccountโ,
โcontentโ: โโ,
โcontent_typeโ: โQuestionโ
}, {
โcreated_byโ: โTestโ,
โtextโ: โClicca sulla ttger alla wrtr rtwt lโrewrre er deve ererg la :
โ08-06-2021 05:26 AM
The samples you are sending are pretty hard to understand. Send one sample object before the transformation, and one after, and use the Preformatted text option while posting JSON data.
โ08-06-2021 05:39 AM
the sample input.
"chathist": [{
"created_by": "Test",
"text": "Account",
"content": "",
"content_type": "Question"
}, {
"created_by": "USer1",
"text": "Clicca sulla ttger alla wrtr rtwt l'rewrre er deve ererg la :<b><br><br><ul><li><a role=\"button\" tabindex=\"0\" class=\"mccs-input\">ffdgc!</a>",
"content": "",
"content_type": "text"
}, {
"created_by": "User1",
"text": "Management ",
"content": "",
"content_type": "Question"
}, {
"created_by": "Test",
"text": "Quale resettare?<b><br><br><ul><li><a role=\"button\" ",
"content": "",
"content_type": "text"
}, {
"created_by": "User1",
"text": "Reset Xchanging",
"content": "",
"content_type": "Question"
}, {
"created_by": "User1",
"content_type": "Mps",
"content": {
"intent": "changing",
"video_URL": null,
"solution_URL": "",
"title": "Reset changing",
"text": "Scriva una e-mail a<strong> xch-helpdesk@xchanging.it</strong><span style=\"color: black;\">oppure si sul desktop l'icona </span>"
}
}]
the example sample output.
VA history:
User1: IBM Demo: What is LUCA
VA: What is MNCQ Answer: MNCQ stands for dafsasf.
User1: Marked the solution NOT helpful. Comment: needs additional detail
VA: Feedback recorded
VA: feedback to improve. view the other.
User1: window login
VA: Please click for your query. If you do not wish ask any other question.