Validation on list within the same period - sharepoint

We have SharePoint list to register the employee sick absence, the HR user sometime register duplicate absence or in the within the same absence period for the same employee, example the following record :
Name : Tony
ID :400
Sick Leave start_date 3/27/2018 AM
Sick Leave end_date 3/29/2018 AM
Total days : 3
per the example by mistake the HR user add new sick leave for tony on 3/28/2018 without he notice he already take a leave from 3/27/2018 to 3/29/2018 .
So the question How we can add validation to restrict adding record in the same absence period

You could use PreSaveAction to do client side custom validation,so you could use REST api or JSOM to query whether user has apply a request already, when return false, the list item won't save.
Check the sample here

Related

SharePoint online reset ID number every year

I'm new in SharePoint online.
I've created a list, customized its form and flows.
But my question is aside from deleting the list to reset the ID number is there a way to reset it every year automatically without deleting the list? So that I'm not going to recheck and re-edit the form of the list.
Like for example today 2019 the ID count is over 500+ and by next year 2020 the ID number will reset into 1 or 0. So in short, ID number will reset every end of the year.
My list number is depending on ID number.
Example.
eNUM-2019-000
eNUM-2019-001
...
then for next year
eNUM-2020-000
eNUM-2020-001
...
In SharePoint Online, we can't reset the list item ID directly.
As a workaround, we can save the list as template and create new list base on the template in the new year begin.
Or you can create another Number column and maintain the ID in the new column.

Advanced lookup formulas based on a combination of unique rules

I am creating an attendance tracking form for work and require someone with more advanced knowledge of excel. This is to track employee tardy's and unplanned absences (UPT). When employees get too many tardy's or UPT's it is called an "Occurrence", when the number of occurrences increase it will increase the "Action Level". I input new data every 2 weeks and then send out emails to notify employees and their managers of increased action levels due to these attendance issues, I want this spreadsheet to do some of the work for me since I am working with hundreds of employees and so the process can sometimes take multiple days to complete.
My objective is to populate the Employee overview cells with the correct details from the Attendance Details page. The challenging part is that there are three rules that dictate which dates I need to populate the Employee Overview with.
Rule 1: Four tardies (TAR) makes an occurrence.
Rule 2: One UPT makes an occurrence, but if there can be multiple UPT's that only make one occurrence as long as they are within 5 days of each other.
Rule 3: Tardies and UPT's disappear after 365 days.
The increase of occurrences will increase the action level (See table in Employee Overview Screenshot).
In my example screenshots, the details should produce the hardcoded Employee overview I made for Bob Smith. I am not expecting anyone to have all the answers, but please help me by suggesting tips or tools available for accomplishing what I require. Please ask any clarifying questions if you wish to help but don't understand what I am requiring.
Screenshot of Attendance Details
Screenshot of Employee Overview for Bob Smith (Hardcoded)
I propose :
break the task/evaluation
Each rule may generate a set of new cell/data/table. thus, work with 1 rule first.
Repeat for another rule.
Consolidate.
these are just my head thinking out loud... hope it helps in anyways.. (care to comment? :)
Rule 1 : =if(countif(<TarRange>,"TAR")>=4,1,0) OR =countif(<TarRange>,"TAR")/4
Rule 2 : make a new list of "UPT"& its date, work from there. arranged the data by date, and use =if((day(<NextEntryDate>-day(<previousEntryDate>))<=5,<currentEntrydate>,"")
Rule 3 : every date cell values can be extracted using year(),month() and day(). Also look in to days calculation in excel help. I see that you'll need an extra column (beside the Rule 2 list) to do a moving summation. An example of moving summation is in the column H & I inside this post :
it uses if(<Day1>=<Day2>,<Count>,<DontCount>) Syntax. it can be change to year1/year2 in your case.
IMHO. Do share with us if you are stuck/successful. (:

SharePoint Calculated Field resets on item edit

I am using a SharePoint list that was migrated from an old Windows 2003 server to an existing 2008 server. This list is used to track issues raised by users against another application - a list of jobs to do if you will.
In the old list there was an Id field. When the list was recreated in the new area the assigned ID number was different, for example
Old ID New ID
--------- ---------
5 204
6 2
7 3
8 159
9 4
This assignment does appear to be fairly random.
To negate this a calculated column was created, so IDs raised before the migration use the Old ID number, and new calls raised after the migration use a calculated value. The calculation is
=IF(ISBLANK([ID (Old)]),ID+8,IF([ID (Old)]<=348,[ID (Old)],ID+8))
This compares the ID (Old) to blank, and if so, it is a new call and should have the default ID number, plus 8 (I think there was a total of 8 calls made during development that were then removed).
Otherwise if the Old ID number is less than 348 (the call number when we migrated), use the Old ID number.
If neither condition is met, simply set the ID to the new ID number plus 8.
This works fine when creating new calls.
The problem arises when I edit a call. For example if I set the ETA to a new value and save the call, the Calculated ID is always reset to 8.
I can fix this by going in to List Settings -> Opening the calculated column -> and clicking OK. This reapplies the calculation and everything is numbered correctly again.
For information - due to the environment this is deployed in I am not able to use SharePoint Designer at all.
The question is, how can I stop the renumbering when I edit an item?
The ID field behaves a bit oddly with calculated columns. A calculated column formula will find the ID of an item and resolve it properly when items are created or when the formula is modified, but as you discovered, when an item is modified, the formula can't find the ID value. (My guess is that this has to do with the ID field not being included in the list of column values being sent to the database on update, perhaps because the ID field should never change.)
One way around this is to use a workflow (or a custom event handler, if you have too much time on your hands) to copy the ID field to another column, such as a number or single line of text column, whenever an item is created. You can then use that new column in your formula instead of using the ID column.
To prevent people from updating your dummy ID column, you can hide it from the forms. To do this, first enable management of content types for the list, then edit the Item content type, find the new dummy ID column, and change it to "Hidden" (instead of "Required" or "Optional").

Restart ID of an item in Mongoose

Good morning friends. I'm using Google translator, so I apologize for mistakes in the text.
I'm developing a system based on MEAN.
I'm using a plugin called mongoose-auto-increment to generate the ID numbers of each item in my database. So far so good, but the problem is that every January 1st at 00:00 hours that ID must be restarted again, ie, the first item stored in the database the new year must have the ID Number 1 and go adding the following.
This obviously without overwriting the article with the ID number 1 of the previous years.
I've been researching a lot but can not find any solution to my situation, I'm probably not using the right keywords. I appreciate any help you can give me.
Best regards :-)
ID's are unique. If you want to use the same incrementing range twice, you'll need to make it unique somehow. Perhaps make the id custom and prepend the year. 2014_1, 2014_2 etc will play nice with 2015_1, 2015_2 etc
Your alternative is just to index a secondary field (perhaps named "alternateID" or whatever) and leave the _id to generate by itself - then query from the alternateID field instead.

Create View Eliminating Records of X Date

I am trying to create a view to find records of a certain date but the results are not what I want for an end result.
To start I want to view records who's start date is 3 weeks out. Simple enough.
.... StartDate | Next X Weeks | 3
This gets my records that are 3 weeks out cool......but it also returns records that are 1 week and 2 weeks out...which I don't want....but I don't see any way to exclude when working with dates? For example this psuedo query....
.... StartDate | Next X Weeks | 3
.... StartDate | ! Next X Weeks | 2
.... StartDate | ! Next X Weeks | 1
Now I haven't dug into seeing if this can be done by writing FetchXML directly....I figured Msoft would have addressed this by now and incorporated it into the UI...but perhaps I am wrong?
The UI only incorporates a subset of available operators. You could, However, use a dynamically built fetchxml which allows you to use the greater then operator and a specific date (today + 3 weeks).
But this means you need to create your own view using something like the following using a webresource or an iframe.
Well unfortunately this logic isn't capable with FetchXML alone http://msdn.microsoft.com/en-us/library/gg309405.aspx
The "not" concept doesn't apply to dates, otherwise you could use the AND logic you specified above.
You can however create a web resource and then query the data you want via JCL or another library. Then you can parse the results to filter the first two weeks via JavaScript.
Or you can create the view with 3 weeks and sort by the date descending. This leaves extra noise at the end of the view, but may suffice.
I am very grateful to Paul & ad1ka's responses and they definitely taught me something new. However both were not quite what I was looking for and that I'm quite confident that is only because of my poorly worded question.
Here is what I ended up doing and feel free to comment / criticize.
I created a DateConmstants entity and added five records (there will be more). (The records have a name, date, and corresponding view name that it applies to).
I then created a maintenance workflow that executes every night to update the dates. For example record 1 is always to be 2 weeks out so the nightly workflow will update the record with the process exec time + 14 days.
I then created the views needing dates adjusted...(with bogus dates for now)
with OnOrAfter and OnOrBefore thus creating a date "sandwich".
I then created a custom workflow that updates these views. It takes an input array of the views to be updated and the records from dateconstants that match the view.
The workflow then finds the view, loads the fetch into an xml. Using the xml find single node I find the OnorAfter and OnOrBefore values and update them. Then push the xml back to to query definition. Update and publish changes.
Finally this is scheduled as part of the afore mentioned nightly maintenance job.
So every day the users have views displaying the correct records with nothing extraneous.
FWIW

Resources