Carousel Script not working
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 05:45 AM
Hi Community,
I'm designing a new topic to request a Catalog Item. First step is to ask the category, then to display all the Catalog Item related to it. For that, I want to use a carousel. I took inspiration of an existing OOTB Carousel Items script but mine is not working and I cannot find why... Does someone see a mistake in my script?
(function execute() {
var baseURL = gs.getProperty('glide.servlet.uri');
var gr = new GlideRecord('sc_cat_item');
gr.addQuery('category', Category);
gr.addQuery('active', true);
gr.query();
var options = [];
for (var i=0; i < gr.length; i++) {
options.push(
{
'Name': gr[i].name,
'Value': gr[i].sys_id,
'Description': gr[i].description,
'Body': baseURL + gr[i].picture
}
);
}
options.push(
{
'Name': gs.getMessage('None of these'),
'Value': gr.length + '',
'Body': baseURL + 'not_viewable.png'
}
);
return options;
})()
Thanks in advance !
Arnold.
- Labels:
-
Virtual Agent
-
Virtual Agent Designer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 05:55 AM - edited 10-03-2023 06:01 AM
Hi ,
please write something like this
var category = vaInputs.HereCategoryVarName.getDisplayValue() returns the label for the variable input. By default, returns the label display value for the selected record.
var baseURL = gs.getProperty('glide.servlet.uri');
var gr = new GlideRecord('sc_cat_item');
gr.addQuery('category', Category); // I think you forgot to get user input here
gr.addQuery('active', true);
gr.query();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 06:01 AM
Hi @hreddy , thanks for your answer !
I actually did. "Category" is the name of the variable containing the user's input
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 06:03 AM
can you send your latest script
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2023 06:14 AM
It is the one from my first message, but here it is:
(function execute() {
var baseURL = gs.getProperty('glide.servlet.uri');
var gr = new GlideRecord('sc_cat_item');
gr.addQuery('category', Category);
gr.addQuery('active', true);
gr.query();
var options = [];
for (var i=0; i < gr.length; i++) {
options.push(
{
'Name': gr[i].name,
'Value': gr[i].sys_id,
'Description': gr[i].description,
'Body': baseURL + gr[i].picture
}
);
}
options.push(
{
'Name': gs.getMessage('None of these'),
'Value': gr.length + '',
'Body': baseURL + 'not_viewable.png'
}
);
return options;
})()