- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-09-2022 07:21 AM
I'm attempting to use EVAM to show cards of other incidents that were created by the same user. The use case is that the technician when viewing the ticket can see in contextual sidebar a list of other incidents created by the same user. This means I can't use the dynamic user is me query. I got this up and running with a EVAM Data Resource and a TRANSFORM script as a demo, but EVAM and TRANFORM just isn't viable for production as the transform only applies the filter after the EVAM call gets a page of records. This means that if the user's incidents aren't in that page of cards it isn't displayed and querying pages and pages of records to do a pseudo-filter on the table is obviously not the solution.
I tried my hand at using the Search EVAM Data Resource, but it seems that the search functionality is too fuzzy since I can't specify just a match in the caller field.
Is there functionality I'm missing? I considered using a filter component as a possible undocumented feature but that didn't play out. I found this community article that seemed promising, but seems to be set inactive.
Right now my fallback is to just use a repeater component, but that feels like a shame because EVAM so perfectly matches my use case short of this issue. Maybe a future enhancement if it's not possible at all? Any tips or ideas about where to look next would be greatly appreciated.
Solved! Go to Solution.
- Labels:
-
UI Builder : Next Experience
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2022 08:11 AM
They way SN is doing this, is rather than just using the EVAM Data Resource which just pulls the data directly based on the definition, they first use the the Fetch EVAM Metadata data resource which pulls the underlying EVAM metadata for a specific definition. This lets us manipulate the EVAM definition within a client script or data broker at runtime, enabling dynamic queries based on things like page properties or user interactions.
After pulling the EVAM Metadata, SN is adding a query to each of the data resources with a scriplet data resource. Create your own data resource of type scriptlet, with inputs for the EVAM Metadata and the query to be used. The output of the Fetch EVAM Metadata will be the input for this resource along with the query. In the SN SOW implementation, source of the query is a little more complex as it depends on the vizualization the user has interacted with, but any encoded query will work, in my case I just have a single state parameter that gets updated based on a field value.
Manipulate EVAM Properties:
[
{
"name": "evam_metadata",
"label": "EVAM Metadata",
"description": "Output of fetch EVAM metadata",
"readOnly": false,
"fieldType": "object",
"mandatory": true,
"defaultValue": ""
},
{
"name": "query",
"label": "Query",
"description": "Query to be updated as template predicate",
"readOnly": false,
"fieldType": "string",
"mandatory": true,
"defaultValue": ""
}
]
Manipulate EVAM Script:
function transform(input) {
var dynamicQuery = input.query.endsWith('^EQ') ? input.query : input.query + '^EQ';
var datasources = input.evam_metadata.datasources;
for (var index in datasources) {
datasources[index].query = dynamicQuery;
}
input.evam_metadata.datasources = datasources;
return input.evam_metadata;
}
The output of the manipulation, which tweaks the EVAM definition with the query, can then be the input for a Fetch EVAM Data type data resource instance, not to be confused with the EVAM Data Resource. Fetch EVAM data has an input for EVAM Metadata which can be set to the output of the manipulate EVAM scriptlet. Cursor, page size, page number and evam filter preference inputs can all be treated like they were with a EVAM Data Resource. FYI, the input data binding will need to be dotwalked to just the definition object; in my case .output.data.GlideCompositeDataMetadata_Query.getMetadata
At this point, we are almost there, we have requested the EVAM data with out dynamically defined EVAM Definition, but it still can't used in a data set component just yet. There is a final step, using the Bind Data to Component data resource on the Fetch EVAM Data output. Its input, GraphQL data should be the output of the fetch. This data resource already exists and basically resolves the items and actions, which is necessary before its usage in a data set components Or in their words:
View Template resolver block of EVAM. Performs following key activities -
a) retrieves the actual view component prop-field map, prop-action map corresponding to each data-item that it gets as input from EVAM Data Fetcher
b) runs over each data-item to
 - resolve values for view component props using prop-field lookup
 - translate or sanitize static values for view component prop
 - resolve view component action from prop-action lookup
c) returns list of component with resolved propValues to render each data-item
At this point, you should be getting EVAM just like you were before, but with an additional layer of query added before the EVAM is run.
@Vegard S Thank you so much for the tip on Service Operations Workspace, I just didn't have the time to dig through different ServiceNow implementations of the EVAM to find one that filters beforehand. If your looking for an example for this working in the wild, you can install the Service Operations Workspace ITSM Applications plugin in a dev environment and check out the Service Operations Workspace experience within UI builder. If you navigate to the Home page, Service desk landing page SNC variant, Overview subpage, you can find the functionality discussed above, check out the data resources.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-13-2022 10:32 AM
I'm working on the same thing. Somehow they do it with the Service Operations Workspace, theres evam definitions, but you can filter the cards when you click the data visualization donuts.
Been digging through the code, but it's not super easy to get through
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2022 08:11 AM
They way SN is doing this, is rather than just using the EVAM Data Resource which just pulls the data directly based on the definition, they first use the the Fetch EVAM Metadata data resource which pulls the underlying EVAM metadata for a specific definition. This lets us manipulate the EVAM definition within a client script or data broker at runtime, enabling dynamic queries based on things like page properties or user interactions.
After pulling the EVAM Metadata, SN is adding a query to each of the data resources with a scriplet data resource. Create your own data resource of type scriptlet, with inputs for the EVAM Metadata and the query to be used. The output of the Fetch EVAM Metadata will be the input for this resource along with the query. In the SN SOW implementation, source of the query is a little more complex as it depends on the vizualization the user has interacted with, but any encoded query will work, in my case I just have a single state parameter that gets updated based on a field value.
Manipulate EVAM Properties:
[
{
"name": "evam_metadata",
"label": "EVAM Metadata",
"description": "Output of fetch EVAM metadata",
"readOnly": false,
"fieldType": "object",
"mandatory": true,
"defaultValue": ""
},
{
"name": "query",
"label": "Query",
"description": "Query to be updated as template predicate",
"readOnly": false,
"fieldType": "string",
"mandatory": true,
"defaultValue": ""
}
]
Manipulate EVAM Script:
function transform(input) {
var dynamicQuery = input.query.endsWith('^EQ') ? input.query : input.query + '^EQ';
var datasources = input.evam_metadata.datasources;
for (var index in datasources) {
datasources[index].query = dynamicQuery;
}
input.evam_metadata.datasources = datasources;
return input.evam_metadata;
}
The output of the manipulation, which tweaks the EVAM definition with the query, can then be the input for a Fetch EVAM Data type data resource instance, not to be confused with the EVAM Data Resource. Fetch EVAM data has an input for EVAM Metadata which can be set to the output of the manipulate EVAM scriptlet. Cursor, page size, page number and evam filter preference inputs can all be treated like they were with a EVAM Data Resource. FYI, the input data binding will need to be dotwalked to just the definition object; in my case .output.data.GlideCompositeDataMetadata_Query.getMetadata
At this point, we are almost there, we have requested the EVAM data with out dynamically defined EVAM Definition, but it still can't used in a data set component just yet. There is a final step, using the Bind Data to Component data resource on the Fetch EVAM Data output. Its input, GraphQL data should be the output of the fetch. This data resource already exists and basically resolves the items and actions, which is necessary before its usage in a data set components Or in their words:
View Template resolver block of EVAM. Performs following key activities -
a) retrieves the actual view component prop-field map, prop-action map corresponding to each data-item that it gets as input from EVAM Data Fetcher
b) runs over each data-item to
 - resolve values for view component props using prop-field lookup
 - translate or sanitize static values for view component prop
 - resolve view component action from prop-action lookup
c) returns list of component with resolved propValues to render each data-item
At this point, you should be getting EVAM just like you were before, but with an additional layer of query added before the EVAM is run.
@Vegard S Thank you so much for the tip on Service Operations Workspace, I just didn't have the time to dig through different ServiceNow implementations of the EVAM to find one that filters beforehand. If your looking for an example for this working in the wild, you can install the Service Operations Workspace ITSM Applications plugin in a dev environment and check out the Service Operations Workspace experience within UI builder. If you navigate to the Home page, Service desk landing page SNC variant, Overview subpage, you can find the functionality discussed above, check out the data resources.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-15-2022 09:43 AM
Hi Thomas! It’s funny you mention it cause I did this exact same thing yesterday 🙂
Even better! Throw in a record watcher data resource in there and listen to your query, then refresh the Evam data on the event from the record watcher and boom you got live updates 🙂