Skip to main content
Nintex Community Menu Bar
Question

get current date range of calendar

  • July 10, 2024
  • 4 replies
  • 49 views
  • Translate All

Forum|alt.badge.img+18

Is there a way I can get a calendar component’s current date range?

This topic has been closed for replies.

4 replies

Forum|alt.badge.img+2
  • July 10, 2024

This would be excellent to know also 🙂

Translate

Forum|alt.badge.img+10

Matt,

Would something like this work? I added a button to a calendar page to run this script.

This was built in Skuid 11.0.3. The calendar filter conditions may have different names in earlier versions.

Thanks,

Bill

var params = arguments[0],
$ = skuid.$;

var ev=skuid.model.map().Events;

var cons = ev.conditions;

console.log(cons);

var start, end;

for (i = 0; i < cons.length; i++) {
console.log(cons[i].name);
if (cons[i].name.includes(‘startlimit’)) {
start = cons[i].value;
}
if (cons[i].name.includes(‘endlimit’)) {
end = cons[i].value;
}
}

console.log('Start value-> ’ + start);
console.log('End value-> ’ + end);

Translate

Forum|alt.badge.img+18

Thanks, Bill.

When skuid doesn’t have a canned method, do it by brute force!

Translate

Forum|alt.badge.img+18

Quick update on this code.

Since the event models seem to have the calendar date range conditions at the end, we’ll start looping through the conditions at the end instead of the beginning, and stop as soon as we have both start and end.

var model = skuid.$M('TargetModel'),
    cons=skuid.$M('EventModel').conditions,
    start, end, i = cons.length - 1;
while (i >= 0 && (!start || !end)) {
    if (cons[i].name.includes('startlimit')) {
        start = cons[i].value;         model.setCondition(model.getConditionByName('start'),start);
    }
    if (cons[i].name.includes('endlimit')) {
        end = cons[i].value;         model.setCondition(model.getConditionByName('end'),end);
    }
    i--;
}
 
model.updateData();```
Translate