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

hreddy
Tera Expert

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

 

 

Hi @hreddy , thanks for your answer !

I actually did. "Category" is the name of the variable containing the user's input

 

arnoldha_0-1696338023865.png

 

can you send your latest script

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