- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-15-2024 09:02 PM
Hey there!
I've converted an existing application still in development to a NowSDK version of it and I've ran into a problem when it comes to declaring the type parameter of the GlideRecord class. I want to be able to dot-walk into the GlideElement objects of the GlideRecord one like in the example below which I've invented.
import {
GlideAggregate,
GlideDateTime,
GlideRecord,
GlideScopedEvaluator,
} from '@servicenow/glide'
export default class AccessRequestAPI {
endpoint_gr: GlideRecord<HTTPMethod>
rest_message_gr: GlideRecord<RESTMessage>
constructor(endpoint_gr: GlideRecord<HTTPMethod>) {
this.endpoint_gr = endpoint_gr;
this.rest_message_gr = this.endpoint_gr.rest_message.getRefRecord(); // Returns String -> Error cause not a valid type
}
}
I know I can use the "any" type and TypeScript will hide the message when the transpiler is set to not strict but having it as strict is a best practice and I want to know if there's a way that I'm not seeing to achieve this.
Thanks in advance!
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-16-2024 05:20 PM
Hi @UIB Whisperer,
We donot support dot-walking for table fields or other types in GlideRecord yet.
As of now, the sole purpose of the types in "@servicenow/glide" package is to provide intelli-sense in the IDE and to make modules aware of the Glide APIs available at runtime.
And types for "RestMessageV2" are available under the "sn_ws" namespace, which can be imported in modules using
import { RestMessageV2 } from "@servienow/glide/sn_ws"
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-16-2024 05:20 PM
Hi @UIB Whisperer,
We donot support dot-walking for table fields or other types in GlideRecord yet.
As of now, the sole purpose of the types in "@servicenow/glide" package is to provide intelli-sense in the IDE and to make modules aware of the Glide APIs available at runtime.
And types for "RestMessageV2" are available under the "sn_ws" namespace, which can be imported in modules using
import { RestMessageV2 } from "@servienow/glide/sn_ws"
Thanks
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-16-2024 05:55 PM
Hey @Venkat79, thank you for your response. I did figure out the module where those are exported but could not figure out the part on how to implement a typed GlideRecord. Is this last one going to be addressed? If so, anytimeline?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
ā09-17-2024 09:05 AM
Hi @UIB Whisperer, Yes we will be adding support for Typed GlideRecord but I won't be able to provide a timeline. Sorry.
- Venkat