Introduction
If you are new to Dynamics 365 portals, Please refer our earlier article for setting up Dynamics 365 trial and you can refer to this KB to provision portal in your trial.
Requirement
Solution
The above code will get service appointment record for us based on the customer id from the query string parameter. Now we need to get an appointment date from the FetchXML result. While getting an appointment date we will be formatting date using “%y%M%d” combination, you can see liquid date format options here. We will also convert the value to int for easy comparison. You can check the complete list here for working with the different data type filters. While working with the above format I faced an issue for the padding 0, so in case the day is < 10 it was returning single number, for example if today is 2, it returned 2 instead of 02, to get a two digit day and month I used "%y%0M%0d" option if both month and day are <10. So to get today's days with two digit numbers I used the following code.
Further, the above code can be used to get a customer appointment date as well in the same format and finally we can use the following code to compare the date with the current date to check if the appointment date is in the future or not.