Automatically refresh list control

i have a form with list control in it.
how can i automatically refresh the list control content, since other users are adding data to the list and i need those updates to be reflected automatically to the list control
regards

1 Like

Hi @MehmetMuhanna,

Try this approach: Refreshing a List or Library control - #8 by Nikita_Kurguzov
Let me know if this works for you.

Thak you very much.
i do have this Refresh button, but i want the list control to automatically refresh based on time interval (5 Seconds)

Hi @MehmetMuhanna,

For that, use this code:

fd.spRendered(() => {
    setInterval(() => {
        fd.control('ListOrLibrary')._dataProvider.refresh();
    }, 5000);
});

i am sorry but this does not work here is my code
fd.spRendered(function () {
//set list refresh interval
setInterval(() => {fd.control('ListOrLibrary1')._dataProvider.refresh();}, 5000);
// set the edit dialog box size
fd.control('ListOrLibrary1').dialogOptions = {
width: 1280,
height: 720
}
fd.control('ListOrLibrary2').dialogOptions = {
width: 1280,
height: 720
}
fd.control('ListOrLibrary3').dialogOptions = {
width: 1280,
height: 720
}
// Dynamic Search list 2
var dt = fd.control('ListOrLibrary2');
/* dt.ready(function() {
filterDT();
});*/
fd.field('TicketSerialNo').value = "";
//filter List or Library with new value when Search field changes
fd.field('TicketSerialNo').$on('change', function() {
if (fd.field('TicketSerialNo').value > 0) {
filterDT();
} else {
dt.refresh();
}

});

function filterDT(){
    dt.filter = "<Contains><FieldRef Name='Ticket_x0020_Serial_x0020_Number'/><Value Type='Text'>"
        + fd.field('TicketSerialNo').value + "</Value></Contains>";
    dt.refresh();
}

// End of Dynamic Search
// Dynamic Search List 3
var dt1 = fd.control('ListOrLibrary3');
/* dt.ready(function() {
filterDT();
});*/
// fd.field('TicketSerialNo1').value = "";
//filter List or Library with new value when Search field changes
fd.field('TicketSerialNo1').$on('change', function() {
if (fd.field('TicketSerialNo1').value > 0) {
filterDT1();
} else {
dt1.refresh();
}

});

function filterDT1(){
    dt1.filter = "<Contains><FieldRef Name='Ticket_x0020_Serial_x0020_Number'/><Value Type='Text'>"
        + fd.field('TicketSerialNo1').value + "</Value></Contains>";
    dt1.refresh();
}

// End of Dynamic Search
fd.field('Priority').$on('change', function (value) {
if (fd.field('Priority').value == 'Urgent'){
$(fd.field('Priority').$el).find('span.k-dropdown-wrap.k-state-default').css('background-color','red');
}
if (fd.field('Priority').value == 'High'){
$(fd.field('Priority').$el).find('span.k-dropdown-wrap.k-state-default').css('background-color','orange');
}
if (fd.field('Priority').value == 'Medium'){
$(fd.field('Priority').$el).find('span.k-dropdown-wrap.k-state-default').css('background-color','brown');
}
if (fd.field('Priority').value == 'Low'){
$(fd.field('Priority').$el).find('span.k-dropdown-wrap.k-state-default').css('background-color','green');
}
});
fd.field('Ticket_x0020_Status').value = 'Open';
fd.field('Ticket_x0020_Status').disabled = true;
});

Hi @MehmetMuhanna,

Please change fd.control('ListOrLibrary1')._dataProvider.refresh(); to fd.control('ListOrLibrary1').refresh(); in the code. I used an outdated function by mistake.

1 Like

it is working fine, thank you very much