AnsweredAssumed Answered

Create autocomple script for a master list

Question asked by angieguti on Jan 27, 2016
Latest reply on Jan 29, 2016 by angieguti

Good morning,

 

I need to create a script to have the AutoComplete function in a field with information "segmentoedicioncentrocostos" field of a master list called "WFMASTERCOL SEGMENTOEDICION Y CC". Create the following script but doesn't work me, Can you help me?:

 

NWF$(document).ready(function () {
    autocompleteSetup(NWF$('.autocomplete.segmentoedicion').find('input:not(.nf-hidden-associated-control)'));
});

function autocompleteSetup($elem) {
    NWF$.each($elem, function (i, item) {
        NWF$(item).autocomplete({
            source: function (request, response) {
                var autocompleteVals = [];

                var restQuery = "/procesoscts/_vti_bin/ListData.svc/WFMASTERCOLSEGMENTOEDICIONYCC?$filter=startswith(segmentoedicioncentrocostos,'" + request.term + "');
                NWF$.ajax({
                    type: 'GET',
                    url: restQuery,
                    dataType: 'json',
                    success: function (data) {
                        NWF$.each(data.d.results, function (i, item) {
                            autocompleteVals.push(item.segmentoedicioncentrocostos);
                        });
                    },
                    async: false
                });

                response(autocompleteVals);
            },
            minLength: 3
        });
    });
}

 

 

Thanks!

Outcomes