Carousel Script not working

arnoldha
Tera Guru

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;
})()

arnoldha_0-1696337113756.png

 

Thanks in advance !

Arnold.

6 REPLIES 6

Please copy+Paste this code and let me know

(function execute() {

var baseURL = gs.getProperty('glide.servlet.uri');
var cat = vaInputs.Category.getDisplayValue() || vaInputs.Category.getValue();
var gr = new GlideRecord('sc_cat_item');
gr.addQuery('category', cat);
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;
})()

I tried your code, but the outcome is still the same