Summary: My function-based Action that tries to set a GeoPoint as a Geohash property is failing with an error suggesting it was anticipating a string.
I have an Object Type with a String property that has been designated as a Geohash in the property editor. The field in the underlying dataset consists of strings representing lat,long pairs, formatted as '12.123456,34.345678'.
Subsequently, I have a function-based action for modifying Objects of that Object type. It is currently configured to accept a string as input (using the regex
^-?[0-8]?\d\.\d+,-?1?[0-7]?\d\.\d+$
for Submission Criteria to ensure it adheres to the expected lat,long format). The Typescript function then assigns it to the Object Type as a GeoPoint like this:
@Edits(myObjectType)
@OntologyEditFunction()
public editMyObjectType(
myObject: myObjectType,
.....
latlong?: string,
.....
): void (
.....
let geopoint = latlong? GeoPoint.fromString(latlong) : undefined;
.....
const cols: Partial<myObjectType> = {
.....
coordinate: geopoint
.....
}
Object.assign(myObject, cols);
}
This does not lead to any errors. When I hover over coordinate
within the cols
variable, the tooltip indicates that, based on the imported Object Type of which it is an example, it anticipates a value of type GeoPoint | undefined
. Clearly, GeoPoint.fromString(latlong)
, where latlong
represents a string, effectively stores a GeoPoint in geopoint
(when not undefined).
Nevertheless, when attempting to submit the Action in the front end, I encounter the following error:
Failed to apply change.
Error: [Actions] PropertyTypeDoesNotMatch
Error ID: <a UUID>
Related values:
- propertyTypeRid: Optional[ri.ontology.main.property.<another UUID>]
- expectedType: Optional[ValueType{value: PrimitiveWrapper{value: STRING}}]
- actualType: Optional[Value{value: GeohashWrapper{value: 12.123456,34.345678}}]
The value at the end, 12.123456,34.345678
, consistently corresponds to whatever is entered into the latlong field under consideration.
It seems that the Object Type is foreseeing receipt of a string from the function, even though in the Typescript editor it anticipates a GeoPoint and generates an error if a string is attempted to be provided. Why is this discrepancy occurring?
Edit: Furthermore, the function operates smoothly during testing in the Live Preview of the Typescript editor, producing an Object with attributes such as coordinate: 12.123456,34.345678
.
Edit 2: I understand now that a GeoPoint is not simply a lat,long string but rather a structure containing distinct lat and long values. This raises the question: why, in TypeScript, does it interpret the coordinate
property of myObject
as a GeoPoint initially? Why is it not permissible to assign it a string?