02-06-2019 09:37 AM
We are having an issue with the api… where we are getting un-parsed json data as part of the api return for the “details” field.
Here is the api return:
[ { "id": "b96563e3-f9a8-4ef0-b3f2-ddecf8400ee6", "manageUserID": "14e85f33-d94e-42a1-8d14-6292879fcc88", "createUserID": "14e85f33-d94e-42a1-8d14-6292879fcc88", "isPrivate": false, "details": "{\\rtf1\\ansi\\ansicpg1252\\deff0\\nouicompat\\deflang1033{\\fonttbl{\\f0\\fnil\\fcharset0 Tahoma;}{\\f1\\fnil Tahoma;}}\r\n{\\colortbl ;\\red198\\green0\\blue198;}\r\n{\\*\\generator Riched20 10.0.17134}\\viewkind4\\uc1 \r\n\\pard\\cf1\\b\\f0\\fs24 G3894 v 3.1.1, 6.7.0\\par\r\n8GB Micro SD & USB\\par\r\nshipped 1/25/19\\par\r\nVAMC West Haven for Charles Frank Ternes\\f1\\par\r\n}\r\n", "regarding": null, "duration": "5 minutes", "startTime": "2019-01-25T16:57:00-05:00", "endTime": "2019-01-25T17:02:00-05:00", "outlookID": null, "historyTypeID": 1016, "historyType": { "id": 1016, "name": "UPS", "description": "UPS" }, "created": "2019-01-28T16:57:56-05:00", "edited": "2019-01-28T16:57:56-05:00", "companies": null, "contacts": [ { "id": "52c5c910-6c28-4d6b-9475-a56bb5726d89", "displayName": "Charles Frank Ternes" }, { "id": "49b8c26a-e87b-4950-bd41-d2f0bd4725ef", "displayName": "West Haven VAMC" } ], "groups": null, "opportunities": null, "attachment": null } ]
The only data that should be returned for the “details” field should be: VAMC West Haven for Charles Frank Ternes
Can you help?
02-06-2019 10:22 AM
It appears that this is formatting data for font type, size, orientation, etc.
We don't want this as part of the "details" return though. Just need the raw text.
If there was an easy way to parse this data out, we would. But we don't see any parse rules that we could apply since the data is different. Here's a few more examples of the "details" field (in bold is the only data that should be be supplied
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}} \viewkind4\uc1\pard\f0\fs17 AIDS Healthcare Foundation (AHF) opened its first HIV specialty pharmacy in November 2000 in Los Angeles and today, AHF Pharmacy operates 33 pharmacy locations across the U.S.\par }
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fnil\fcharset0 Microsoft Sans Serif;}} \viewkind4\uc1\pard\f0\fs23 He called back and said that his group only meets once a year in October. He will stop by our booth and NFB this summer.\par }
03-02-2019 02:02 AM
You need to remove the RTF formatting use something like the code below.
function stripRtf(str){ var basicRtfPattern = /\{\*?\\[^{}]+;}|[{}]|\\[A-Za-z]+\n?(?:-?\d+)?[ ]?/g; var newLineSlashesPattern = /\\\n/g; var ctrlCharPattern = /\n\\f[0-9]\s/g; return str .replace(ctrlCharPattern, "") .replace(basicRtfPattern, "") .replace(newLineSlashesPattern, "\n") .trim(); }