Lotus View and Date values in column formula - lotus-notes

Hi(sorry for possible dublicate).
I am trying to fix the performance issues in some of the legacy commercial databases which were badly designed in the past.
There are a lot of views in this databases and they are all containing the formulas #Now, #Today values in the view columns in the inner formulas, which are increasing Lotus Views open/refresh speed (as a notice, there is no dates manipulations in the view main selection formulas).
Information in this databases must to be always up to date and refreshed, so the solution with changing the view options (refresh time interval) are not good enough.
I am trying to create a global document (or to find similar solution), which will be updated one time at night with the server agent and will contains fields with year,month and day and trying to add this document as a subform to every document, so this fields with year e.t.c will be accessible in every document and so I could call them in my future column #-formulas and every day this field in this subform will be updated.
Is it really possible/right solution? How can I do that?
Can you please give some advice what is the best way to solve this?
p.s. I have already read a ton of articles about Lotus Views performance issues when using dates and mostly all of them are about creating a server agent, which will update the selection formulas one time per day... but in my variant - I am having a formulas in the columns.
Thank you.
UPDATED 03.03.2018:
Thanks to Knut Herrmann, I have understood that I need to use an agent to update column formulas and that this is possible.
But I am also trying to understand why the view will work faster after the view formula will be updated? Not quite understand this solution.
Why it has no need to update view index every time after one-time formula is updated at the night and why it's refreshing every time now when I am not using this approach?

Use the agent approach.
Change the column formula with NotesViewColumn's Formula property every night:
Dim column as NotesViewColumn
set column = ...
column.Formula = "your column formula"
The idea behind the agent is to avoid #Today in column formulas as this function causes the view to refresh every time it is called.
Example:
Every night at 2 a.m. change column formula (to show the number of days left)
(#Date(Deadline) - #Today) / 86400
to
(#Date(Deadline) - #Date(2018; 03; 04)) / 86400
This way you eliminate the "dangerous" function "#Today" by replacing it with the current date in formula.

Another option would be to add a field to all the documents using the NotesDocumentCollection StampAll() method in a scheduled agent. For example:
dim db as NotesDatabase
dim dc as NotesDocumentCollection
dim todayDate as new NotesDateTime("")
set dc = db.alldocuments() ' Or whatever selection of documents you want.
set todayDate.localtime = format(Now(),"mm/dd/yyyy")
call dc.stampall("TodayDate",todayDate)

Related

Creating report based on input form in MS Access

I am currently developing a database to monitor my employees' work. Yet, MS Access is new to me and I encounter a fundamental problem when creating reports.
I wish the system can generate reports based on the values of an input form. Say, I would like to check Peter's work in January, I could simply enter:
Name: Peter
Month: January
Then the Access would be able to generate a corresponding report. But I am not sure how it works. And I am thinking of three possible approaches.
(1) Input form -> Query -> Report
I look up youtube and learn how to build an Access form that passes a parameter value to a query. And then I can click the Create Report button.
(2) Input form -> Report
Not sure it works or not. But I learned a bit VBA which may be helpful in this case.
(3) Export to Excel
Export to Excel might be a good option. I can use various functions and filters to select the information I want.
Sorry that my question is being abstract. Any help is appreciated.
there are many ways you could achieve this.
One way (it may be the most efficient or not depending on your query / data you need to output in the report).
Build the query.
Build a report with its record source based on the query.
Build a form with input controls and a button.
With the button you are going to open the report. In the open statement of the report you are going to specify the controls as filters to some of the fields retrieved by the query.
Example:
Private Sub POrdine_Click()
On Error GoTo Err_POrdine_Click
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "EmployeeWork"
stLinkCriteria="EmployeeCode=" & Forms![frmNameOfForm]![cboEmployeeCode] & " AND WorkMonth=" & Forms![frmNameOfForm]![cboWorkMonth]
DoCmd.OpenReport stDocName, , , stLinkCriteria
Exit_POrdine_Click:
Exit Sub
Am assuming the two comboboxes are going to pass a numerical value, the employee code (which would be a primary key) and the value of the month. Build the queries that feed these controls so that you may see the employee name and the month name. If in doubt just ask.
Notice how this approach may not work well for reports based on large amounts of data.

How to get view data to copy to field in document?

I'm currently tasked to redesign an application form where several fields will need to auto-fill based on the data from a specific field when it is entered.
Since I'm relatively new to LotusNotes, my boss hinted at me to first create a view which displays the fields to auto-fill. Which I did:
| Visitor Name | Company Name | Contact No | Date Entered |
Visitor Name is the field which will determine the data for Company Name and Contact No when it auto-fills in the form. Date Entered will see which data is the most recent and will use that. Also the field must be set as Editable to allow user to change the data if need be.
However, when trying to modify the form, I can't quite get how to link the view together with my desired field in the form.
I tried #DbLookup and created the formula
#If(VisitorName = "";"";VisitorName != ""; #DbLookup("" : "" ; "Local":"D:\LotusNotes Project\HR002a.nsf"; "Visitor View";#text(ContactName);#Text(CompanyName));"")
But it doesn't seem to work when I place it in Default Value or Input Translation. Even changing the filed to Computed doesn't seem to help as well.
What else am I missing in my formula?
You could simplyfiy your formula
#If(VisitorName != ""; #DbLookup("";#dbname;"Visitor View";#text(ContactName);2;[FailSilent]);"")
I am assuming this is a form used in the Notes clieny, not on the web. If this is a web form, you need a different approach.
You could very well use #DBLookup for that task. To improve performance, concatenate all the values into one column, perform the #DbLookup on the form, retrieving the concatenated values, then split them into separate values and populate the different fields.
You could also use Lotusscript. You want to look at the NotesView class and the NotesViewEntry class (assuming you want to build it for performance). Use the ColumnValues property of the NotesViewEntry class to read the columns in the view. Remember that the first column needs to be sorted.
Or your company could hire someone that already know Notes and Domino, and have that done in an hour. That would probably be financially a better choice than you spending hours or days on this fairly simple task. There are many of us here (me included) who could jump in and fix this for your company.

Data import from new reports and automatically update existing records in existing data

I seek expert advice of all of you in accomplishing my work related task.
Task : Task it to perform Analysis on reports obtained to WorkSafe Monthly and weekly and getting valuable information out.
For example :
Number of injuries on monthly basis drilled down by department and divisions.
Total days lost in year
Count of type of claims
Possible return date.
So i receive these reports and i add some modified columns to it. Like Correct employee names and their ID's just to create a relationship between Employee database in Powerpivot so that i could get their position, dept and division.
Now every month in new report there could be 2 or 3 new claims added to it, and some existing claims with updates info. like Updated return to work date, Short term disability days etc.
Currently i go through them manually and it's really time consuming and tiring. if there there was older claims weren't getting updates i could've just imported from a folder using power query and added steps to remove duplicates. However, if i remove duplicate claims using powerquery now, basically i'll be removing same claims with updated info.
Could anyone you here suggest an efficient way to do it with power query or with other approach?
Thanks in Advance. I'd appreciate your time and effort.
If you use PowerQuery and select your source From File -> From Folder, when you choose to combine and edit you will get a table with its first column named Source.Name; which you could use to differentiate the updates.
For instance: If I start with two excel files in the same folder (theoretically, they could be different date source files for you)...
WS1.xlsx:
WS1 - Copy.xlsx:
Then I use the folder they are both in as the source...
(Navigate to your folder as appropriate.)
...and select Combine & Edit...
...and select the worksheet...
Then I get this:
...and it is clear what information came from what source file.

Sharepoint 2013/2016 Calculated Column stops calculating

I have a calculated column in SharePoint On-Premises that shows the number of days till a due date which works perfectly for a day or so then stops calculating, but if I go to the list settings and click the column and click ok then it calculates again?
Has anyone experienced an issue similar to this. I had this issue in both 2013 but within a few weeks moved to 2016 and still the same issue.
I've tried " " blank and also "" empty so not sure if that is causing the issue??
Is it a problem with the formula?
Here is the formula:
=IF(ISBLANK([Due Date])," ",
IF(ISERROR(DATEDIF(NOW(),[Due Date],"d"))," ",DATEDIF(NOW(),[Due Date],"d")))
Calculated columns cannot contain volatile functions, which includes those that depend on the current date.
The values in SharePoint columns--even in calculated columns--are stored in SharePoint's underlying SQL Server database.
The calculations in calculated columns are not performed upon page load; rather, they are recalculated only whenever an item is changed (in which case the formula is recalculated just for that specific item), or whenever the column formula is changed (in which case the formula is recalculated for all items).
If you need to show a dynamic value that changes with the passage of time, you have a few alternatives.
Client-Side Rendering
Consider using client-side rendering which lets you use JavaScript to dynamically determine how records in a list view are displayed. This JavaScript runs upon page load, so it can handle current time-dependent values much better than a calculated column.
To use client-side rendering, you create a JavaScript file that controls how the view displays. You upload that file to somewhere on SharePoint where people will have at least Read access to it, then edit the list view web part that you want to display differently and set its "JSLink" property to point to your JavaScript file.
Check out this answer for an example of using a JSLink file to spoof a dynamic date field.
Microsoft also provides some documentation here but I think they do more work than is necessary (creating an entire new list definition project in Visual Studio for their example instead of just creating a JSLink JavaScript file for an existing list).
Other Options
A few other options are mentioned in the older question linked above:
Conditional Formatting: You can apply conditional formatting to highlight records that meet certain criteria. This can be done using SharePoint Designer or HTML/JavaScript.
Filtered List views: Since views of lists are queried and generated in real time, you can use volatile values in list view filters. You can set up a list view web part that only shows items where Created is equal to [Today]. Since you can place multiple list view web parts on one page, you could have one section for today's items, and another web part for all the other items, giving you a visual separation.
A workflow, timer job, or scheduled task: You can use a repeating process to set the value of a normal (non-calculated) column on a daily basis. You need to be careful with this approach to ensure good performance; you wouldn't want it to query for and update every item in the list if the list has surpassed the list view threshold, for example.
To expand on the Filtered List Views option, you can have a view that shows only items that are due within a certain number of days. For example, you can display all the items due within 7 days by filtering where the Due Date field is less than [Today]+7 and Due Date is greater than or equal to [Today]. You could also sort the view to show the items with earlier due dates closer to the top.

how to call and sort data in a view?

I have two view, one is sorting 2011 data and the other one is sorting the 2012,
2013 is coming and I think, create another view is not good. Then I tried to code a formula to call the data in my database and send to view but it's not working .
please help me :)
I think your best option is to create another view. Notes doesn't do well with dynamic view selection formulas.
Another alternative to consider is to use categories to group data by year. You could then set up an embedded view that shows only a single category, which could be determined by a drop-down field that shows the available years.
A solution I have used when dealing with weekly or monthly date is to use an agent to create a new folder every week and to put the correct documents in the folder. But this is a lot of work and if there is a high volume of data you can run into problems with some of the internal limits of the Notes database structure. Someone with expert level knowledge of Notes can probably manage this, but I do not recommend it as a general solution -- and certainly not for yearly data.
Adding a view once a year is really not that bad. It's two minutes of work every 12 months, just copying and renaming the previous year's view and changing the selection formula.

Resources