Get Started         Best Practices         Developer Guide         FAQ        
Name is required.
Email address is required.
Invalid email address
Answer is required.
Exceeding max length of 5KB

retrieving something from "custom" field

Kent Jan 16, 2018


My app successfully puts a string in the "custom" parameter when creating an item, but I am not able to retrieve it correctly. I know it is there because 1) it appears in the Optional Data "Text Field" in my collection via your Collection Management Dashboard (note: I'm not sure why this isn't labeled "Custom Field" to match your documentation), and 2) when I run the Curl command for Get Item it returns as part of the "Custom : string" data pair. I am able to retrieve the other Item parameter data, as well as Score and Image parameters, but the Custom field returns a web Url. Ex. When I click on this link the data I'm looking for appears in my browser. I expected to be able to simply retrieve the data like I can for other paramaters, but I get this link instead.

Here is my code where you'll see I'm trying various approaches simultaneously. Below that are the results. Can you help me understand how to get at the "custom data" properly? Thanks, Kent

CraftARResult result = results.get(0);
int result1 = results.get(0).getScore();
String name1 = results.get(0).getItem().getItemName();
JSONObject itemJSON = result.getItem().getJson();
String firebaseItemUUID = result.getItem().getCustom();

Both of these yield the same thing for.. itemJSON:

JSONObject itemJSON = result.getItem().getJson();
String stringJsonItem = itemJSON.toString();

String fb = (String) itemJSON.opt("custom");

loading the above link in the browser yields the "custom data" parameter I'm looking for ---> 7cd141f9-416a-4b8a-803c-86f11974f904

1 Community Answers

Best Answer

Jan 16, 2018

I figured it out after finding a reference to embed custom in the V0 documentation. Then a search on embed custom and a dive into the CraftarAR classes led me to add to my search code. True retrieves the value directly, while False returns just the URL which is quicker if you don't need the data immediately and don't want to slow down the search results. Hope this helps someone else.


Post Your Public Answer

Your name (required)
Your email address (required)
Answer (required)

Couldn't find what you were looking for?
seconds ago
a minute ago
minutes ago
an hour ago
hours ago
a day ago
days ago
Invalid characters found