Field Calculator erroring on ":" in string field.

815
2
06-15-2017 10:31 AM
TonyAppel1
New Contributor

I am wanting to calculate a field into a URL that will allow a user to download a file.

I can perform this calculation in ARcmap directly without error, but GeoEvent field calculator cannot.

expression

"http://www.openstreetmap.org/trace/" & Right( [guid], 7 ) & "/data"

Error in Geoevent is

Processor "osmdesk": Field Calculator validation failed: Unable to parse character at position 5: ':'

IS there another way to handle this or work around it?

0 Kudos
2 Replies
RJSunderman
Esri Regular Contributor

Hello Tony -

The GeoEvent Server Field Calculator's expression parser does not accept VB or Python function syntax. It is a simple expression parser with limited support (through wrapper functions) for methods in the Java String Class which return non-list, non-arrayed values (e.g. int or string).

Given an inbound event record:  [{"UserID":"6a3fe3eb-4d6494d","URL":""}]

You could configure a Field Calculator with the following expression to build the URL you are looking for.

'http://www.openstreetmap.org/trace/' + substring(UserID, length(UserID) - 7, length(UserID)) + '/data'

Notice that the literal strings are denoted with single-quotes, not double-quotes. Also, I am using nested calls to length() within my substring() function invocation. I need to specify a beginIndex and endIndex for the string I want to extract from the event attribute UserID. These values can be either computed or hard-coded. If you knew that the user id was always going to be formatted as it is in this example you could use substring(UserID,9,16) instead.

Generally speaking, when invoking one of the Java String methods as a wrapper function, you have to insert the name of the event field you want the function to use as a 0th argument and you must use the most general function signature available (e.g. Java has methods for both substring(int beginIndex) and substring(int beginIndex, endIndex), but the function parser cannot support overloaded function signatures, so you must use the more general of the two and supply both indexes rather than allowing the invocation to assume "from here to the end of the string".

Hope this information helps -

RJ

TonyAppel1
New Contributor

Thanks RJ

My question is this then: The URL that I need to grab the "ID" from is never the same size in length. I just need the last 7 from it.

Example: http://www.openstreetmap.org/user/jojkuhiuwer/traces/2436371 

What does the java look like in that case?

0 Kudos