Disable all dates if empty array is passed into enable parameter in Flatpickr - flatpickr

I just want to know, is there any way to disable all the dates, in case an empty array of dates is being passed into the enable parameter. Currently, I am passing few dates that fetched from the database, there are few cases, where it doesn't fetch any dates, in that scenario I want the calendar dates to be completely disabled. Is there anyway?

The documentation of flatpickr has an example there.
https://flatpickr.js.org/examples/#disabling-specific-dates
There are 3 possibilities:
Disabling specific date
Disabling a date range
Disabling dates using a function
Just follow their examples an you will succeed.
In your case i would use the disabling by a function an return true for every date if your array is empty.

Related

Power Automate - Compare StartDate to current date?

We are looking to compare the calendar start date with the current date in flow. Currently we are pulling the start date through a filter query like this:
formatDateTime('EventDate','M-d-yyy hh:mm')
and comparing to this:
formatDateTime(addDays(utcNow(),3),'M-d-yyyy hh:mm')
I am getting this error currently: "Unable to process template language expressions in action 'Get_items' inputs at line '1' and column '17987': 'In function 'formatDateTime', the value provided for date time string 'EventDate' was not valid. The datetime string must match ISO 8601 format."
Any help on this would be greatly appreciated!
You could Initialize a variable like the following below and then do a IF condition.
#{add(div(sub(ticks(utcNow()),ticks('1900-01-01')),864000000000),2)}
I test with the same formula to convert event start date and it works fine in my end. The if condition returns correct result on different conditions.
Here is the logic of my demo flow, please have a check:
I use get item to get the start date of a certain event in the calendar list and convert the start time dynamic content to the format I need. Almost same with yours.
According to the error message, it seems the format of the event date column is not in the supported format. Would you like to provide the settings of your event date column? I test with the default start time column and a custom date & time column of default settings. Both of them works fine with the flow above.
Update:
The two formulas used are displayed below:
formatDateTime(outputs('Get_item')?['body/Event_x0020_Date'],'M-d-yyy hh:mm')
formatDateTime(addDays(utcNow(),3),'M-d-yyyy hh:mm')
I just directly use the outputs of the data compose action in the if condition
What worked for me was to build a sequence of numbers with the dates being ordered by day, month and year this way, when converting to integer, it's easy to compare
int(formatDateTime(utcNow()),'yyyyMMdd'))
if you need add day for exemple, you can use
int(formatDateTime(addDays(utcNow(),variables('extraDays')),'yyyyMMdd'))
and the other date like this
int(formatDateTime(variables('FinalDate'),'yyyyMMdd'))
Based on your example, you can put hours and minutes without any problems, just remove the special characters and spaces
but by the definition of the error you are having, I believe it is because of the way you are writing the variable

Fetching date value from a SharePoint-list, to use in date&time specific field in flow

I'm trying to design a Microsoft Flow, which will create a outlook calendar event entry based on information in a SharePoint-online list.
The list will contain a value for a DueDate its a column of type Date, not including time.
I want to be able to create a outlook calendar entry on the date based off the duedate column. The calendar entry form in flow allows via dynamic content to add dates that also include time, however date columns not containing time cannot be added that way.
Is there a workaround to this, some expression that would allow me to fetch values from columns more freely and then possible append a time to it
I have tried converting the column in sharepoint to a Date with Time column and that workaround worked, however its not what I'm looking for. Id like to know how to be able to work around this because I don't necessarily want my column as a date-time column which can cause problems later on.
I have tried this expression:
formatDateTime(concat(item()?['DATE'], '08:00')'yyyy-MM-ddThh:mm:ss')
But I know this is wrong and it doesn't work. I'm simply not sure how to do it.
https://puu.sh/Df5ni/05cb882b23.png
I want the flow to add a calendar entry based off the due date column which i can append my own time to like the start of the day and last til the afternoon.
Actual results are I don't seem to be able to use a date column, just a date-time column for start and end times of the event, date column without time doesnt appear in the dynamic content list.
If there is some way to manually fetch values instead of using the dynamic content that is very powerful and can then possibly be converted to the right format using additional code.
Date column name in my list is date_without_time of type Date (Add time set to NO):
New element:
Function used in Create event (V2) action:
formatDateTime(triggerBody()?['date_without_time'],'yyyy-MM-ddT09:35')
Result:
Calendar:

What is the correct way to add a Date Filter to a scripted search (SuiteScript 1.0)?

I have a script built search in SS1.0 that includes a date range filter, however some transactions continue to be included despite their {trandate} being outside the given range.
I have tried both adding filter objects, and using a filter Expression.
Currently it looks like:
filters.push(new nlobjSearchFilter('trandate',null,'onorafter',startdate));
filters.push(new nlobjSearchFilter('trandate',null,'onorbefore',statementdate));
Which should result in retrieving transactions between start date and statementdate inclusive.
Yet, still get results outside the range (ie, before the startdate)
Try below code
filters.push(new nlobjSearchFilter('trandate',null,'within',startdate,statementdate));
Both of those should work. If you have a real dates though make sure you convert them:
filters.push(new nlobjSearchFilter('trandate',null,'onorafter',nlapiDateToString(startdate)));
filters.push(new nlobjSearchFilter('trandate',null,'onorbefore',nlapiDateToString(statementdate)));

PyQt QDateEdit Selection Issues

I have a PyQt application, which contains a QDateEdit. I've set a limit to the date range which can be selected, which is a short range over the boundary of a month, e.g. 28/01/2011 to 02/02/2011.
This seems to break the QDateEdit, because you cannot change the values across the month barrier. Say the default is 28/01/2011: we can't increase the month to 2, because this would result in the date of 28/02/2011, which isn't valid. However, you can't decrease the day, because this would result in 27/01/2011, which isn't valid.
Is this a bug, or does anyone know a way around it?
I just tried this out and it does seem to be the case. I looked at the C++ documentation and it does say this:
QDateTimeEdit can be configured to allow a QCalendarWidget to be used to select dates. This is enabled by setting the calendarPopup property. Additionally, you can supply a custom calendar widget for use as the calendar pop-up by calling the setCalendarWidget() function. The existing calendar widget can be retrieved with calendarWidget().
So maybe you can use that to set the date?
Edit:
The only other thing I can think of is you don't set a min or max with QDateEdit. Then you have a button called "Update Date" that checks the date set for the min/max restrictions. If it doesn't meet those restrictions, it resets the date to what it was previously. If it does meet the restrictions you use the date set.

Any solution to the Today Calculated Column problem is SharePoint?

I would like to be able to use today's date in a calculated column in a SharePoint list to, for example, determine whether a task is overdue. There is a well-documented trick that involves creating a dummy column named "Today," using it in a formula, and then deleting it, thereby "tricking" SharePoint into using the Today function.
The problem is that this method does not work reliably -- the calculation is not dynamic; it is only made when the item is saved, and therefore the Today "column" effectively becomes the Modified Date. (This is probably why SharePoint won't let you use the Today function in a straight-forward way.)
Has anyone found a solution that works? I know I can use javascript to get the actual date on the client side and display colors, flags, whatever, but I am looking for a "server side" solution.
For reference, the Today column trick and its problems are described fairly well at these two posts and associated comments:
http://blogs.msdn.com/cjohnson/archive/2006/03/16/552314.aspx and http://pathtosharepoint.wordpress.com/2008/08/14/calculated-columns-the-useless-today-trick/
There simply isn't a work around for this. As the values for the list are stored in the database and returned "as is" to other featurs such as the search crawler, a dynamic field cannot be created.
It is possible to create a custom field that will display the value using todays date in its calculation.
In addition to Christophe's (PathToSharePoint)'s article this also covers the Today trick and why it doesn't work
The Truth about using Today in calculated columns
There are a number of fudges, probably the best one is Dessie's console app (mentioned above by MNM)
Dynamically updating a SharePoint calculated column containing a Today reference
Its good but its not perfect, for example you may have to worry about different timezones.
Before going down this route you should ask yourself if you really, really need to do this. For example :-
If you want a countdown (days overdue/days left to complete a task) then you can use SPD and a XLST Data View web part
If you want a view to show overdue items or items created in the last X days ec then you can use [Today] in a views filter 2
If you create a Today column it needs to be updated. You can do that with either a timer job or by placing a jquery script on a page that is hit by the user. The script could call SPServices.SPUpdateMultipleListItems to do the update. Pass a CAML clause so that you only update the list items where the Today value needs to be updated, e.g. once per day.
My advice is to create your on field that does this calculation for you and then reference it in your SharePoint list. Not a simple implementation but it would work.
I have been looking for a solution either, still no luck.. The Today column trick has the limitation of not being dynamic.
I do have one suggestion though, why don't we create a timer job that will update a certain a certain column with the current date every day at 12 AM. I know some of you all might think it an over head. Just my suggestion :D!!
I came up with a very rough, but working solution to this problem without having to do any coding. I'll explain both how i made the today column and how i worked that in to an overdue column, becuase that column was a pain to find out how to do as well.
First, I made a column named "today" (gasp!). Next I made a column named "Days Overdue". I then opened up sharepoint designer and created a new workflow. I set it to run every time an item is edited/updated (keep in mind I turned off versioning for this list, otherwise I would have had to resort to coding to avoid a bunch of useless data building up on our server). I set the actions to simply store the modified date in a workflow variable, then change the value of the today column to that variable. although the modified column is a date/time and my today column is just a date, it transfers just fine. I then set the workflow to pause for 2 hours. you can set this to whatever amount of time you want obviously, it will just change the latest possible time for your today column to update, i.e. 2AM in my case.
on to the days overdue column. this is the code for that guy -
=IF([Due Date]>Today,"None",IF([Date Closed]=0,Today-[Due Date],IF([Due Date]>[Date Closed],"None",IF(Today>=[Date Closed],[Date Closed]-[Due Date],IF([Due Date]<Today,Today-[Due Date])))))
This shows the days overdue in number form in days, or if its not overdue, it shows "None". You can use either a number format or a string format, but NOT A DATE FORMAT. Well, I hope this helps anyone who is running into this problem and doesn't want to have to delve into coding.
EDIT: I forgot to say that in the code above for the days overdue column, I put in that if today is past the date closed, to use the date closed minus the due date instead of today minus due date, to ensure that the calculation doesnt keep occurring after an item has been closed. you probably would have noticed that in the code, but i felt i should point it out just in case.
EDIT 2: The code I had in before my 2nd edit for my calculated column didn't calculate the days overdue properly after an issue had been marked "closed." I put in the updated code. The last part of the code doesn't make sense, as it is the same logic as the beginning, but it worked so I didn't want to take any chances! :)
Peace.
I've used the following and had no problems.
Field Name: Overdue
Field Type: Calculated
Data Type Returned: Yes/No
Formula:
=AND([Due Date]<NOW(),Status<>"Completed",[Due Date]<>"")
Here is a workaround:
Create a date column called Today.
Use this column in your calculated formula (ignore the fact that the formula returns a wrong value).
After you are done with the formula, delete the Today column from your list.
For some reason it works this way! Now Sharepoint treats the Today in your formula as today's date.
Note: If you decide you want to change the formula, you have to create the Today column again. Otherwise, it wouldn't recognize Today as a valid column.
I Tried #Farzad's approach and it seems to be working perfectly. I wanted to do a custom count on Days Elapsed so added a calculated column which previously I was using a difference between the Created Date and Modified Date Columns, which was only showing up whenever a user updated the post, much to my dismay.
I now have a formula which works as I would want to and uses the Today column, and here it is for anyone who would like to use it. I also have a Status column on the basis of which a base of On Hold is used, and the remaining formula are based on the date difference of Today - Created.
=IF(Status="On Hold","On Hold",IF(AND(Today=Created,(DATEDIF(Created,Today,"D")=0)),"New",IF(AND(Today<>Created,(DATEDIF(Created,Today,"D")=0)),"New (updated)",IF(DATEDIF(Created,Today,"d")>3,"Need Update Immediately",IF(DATEDIF(Created,Today,"d")=1,"One day old",IF(DATEDIF(Created,Today,"d")=2,"Two days old",""))))))
Basically its just a bunch of nested IF conditions which get me labels on the basis of which I can add a group to my view and filter out data if needed. Hope this helps anyone looking for an answer!

Resources