04-22-2021 02:00 PM
I'm trying to do some development work, and did something I've done many times....put a sample data set into the document repository so I don't have to build a server side just for testing some stuff.
But for the first time, I'm doing this with a JSON document. File uploads just fine, but when I try to retrieve it from the repository in a script, the script engine throws and error saying "Source document variable "myDocument" is not a TextDocument.
This variable contains the name of a file "Employees.txt". That file contains the following simple JSON data:
{
"employees":
{"first_name": "John",
"last_name": "Doe"
}
}
Since this is straight text, I'm not understanding why it cannot be retrieved from the repository. Is this just some weird limitation of UCCX, or am I missing something?
.
Solved! Go to Solution.
04-26-2021 08:32 AM
Ok.....figured out how to do this. This seems kind of a strange way to do this, but it works.
Normally when pulling a document out of the repository, you drop it into a document variable. That won't work if it's a JSON document. What you have to do is drop it into a string variable instead. You can then put the string variable into a document variable and proceed to work with it. This is what worked for me below. The variable types are self explanitory, but "myString" is a string, and "myDocument" is a document. In watching the values in the variables in the debugger, you can see things populating correctly.
04-22-2021 02:25 PM
Do you need to use a "Create File Document Step" first and then use that document object in the "Create JSON Document Step"?
04-22-2021 03:37 PM
I tried that too.....same error.
04-23-2021 06:57 AM
Any difference in your text files that have worked in the past and the new json text files? Encoding, line endings, etc. Sorry, I haven't used JSON text files myself yet, but hope to in the future. Hope you get this sorted out so I don't have to later.
04-26-2021 08:32 AM
Ok.....figured out how to do this. This seems kind of a strange way to do this, but it works.
Normally when pulling a document out of the repository, you drop it into a document variable. That won't work if it's a JSON document. What you have to do is drop it into a string variable instead. You can then put the string variable into a document variable and proceed to work with it. This is what worked for me below. The variable types are self explanitory, but "myString" is a string, and "myDocument" is a document. In watching the values in the variables in the debugger, you can see things populating correctly.
04-26-2021 11:34 AM
Thanks for sharing. Weird quirk, glad you figured it out, I doubt I would have. I assume you could combine the first two lines like this:
Set myDocument = DOC[JsonTest.txt]
04-26-2021 12:26 PM
Nope. That specifically does NOT work. That's what lead to this entire thread.
07-21-2021 09:10 AM
Hi Clifford, read this and I have progressed after days of frustration so thanks :-). Using your JSON txt as an example can you tell me what your JSONpath would be to extract the information on the Get JSON Document Data step?
My JSON is below
[{
"StoreID": 12345,
"TelNo": "08765432123",
"Rang": "false",
"Acknowledged": "false"
}, {
"StoreID": 54321,
"TelNo": "12345678908",
"Rang": "false",
"Acknowledged": "false"
}, {
"StoreID": 908765,
"TelNo": "65465456484",
"Rang": "false",
"Acknowledged": "false"
}, {
"StoreID": 667543,
"TelNo": "6667765444",
"Rang": "false",
"Acknowledged": "false"
}]
I can't seem to get the JSON path correct to get e.g. StoreID e.g. $.[1].StoreID (should be '54321').
Any help would be greatly appreciated.
07-21-2021 02:19 PM
07-22-2021 02:29 AM
07-21-2021 02:59 PM
$[1].StoreID is what will retrieve it. You have an extra dot between the $ and the [.
You can paste your document into the online jayway jsonpath evaluator (this is the method UCCX uses) here and try it for yourself:
07-22-2021 02:32 AM
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide