Helper api.Entity().Data().Get() Cant read after quote mark (")

While rejigging my scripts to try and keep logical and more easily maintained I decided to split the entity data update script to two parts.
First part breaking down the request responce to per room and then Updating entity field with its array and then have a second script to use the individual arrays.
This will make adjusting the way the data is used seperatly to the main request script.

This is a test entity field;

Room Entity: 03, Field: NewBook Site Array = Before"After

HOWEVR this script returns;

return api.Entity('03').Data('NewBook Site Array').Get();

It can only read up to the first ".
So my arrays are being read as only { …

.Update() passes them fine, its just .Get()

@emre any chance of this being something simple you can sort?

I simplified an unused field to test and demonstrate before " and after the "

Other fields return only {

The arrays are quite long.
Dirty work around thought would be to replace all " in the string before the .Update() with something else like ~ and restore them to " after the .Get()
But wanted to report wither way :smile:

1 Like

I don’t remember the exact reason but seems like having quotes inside custom data breaks some cases so I don’t allow that. Better store it as a plain ID and construct JSON/Array string inside JScript.

1 Like

Fair enough, have done as said above using .replace(/"/g,’~’); and .replace(/~/g,’"’)
So I turn the array into;

{~booking_id~:11060,~booking_arrival~:~2016-01-03 14:00:00~,~booking_departure~:~2016-01-09 10:00:00~,~booking_status~:~Arrived~,......................etc

Replacing the " quotes on .Update() and restoring them on .Get()

Annoyingly the .replace(/"/g,’~’) messes up highlighting :frowning: so made the line;

var roomNewArrayStripped = roomNewArrayString.replace(/"/g,'~');//" //Comments

Obviously stripped the quotes after pulling information required :smile:

Probably because custom data is stored in JSON format, so in this case it is storing JSON inside JSON, then trying to parse JSON nested inside JSON. :wink:


It understands it all on the way in though…

But on that principle maybe if I try adding [ ] arround it to make it a sub array…

Eitherway the replace all line in script solved the issue… :smile: