Triggers a notification if TotalDays is ..

hi Experts

I have a form called Employee with the following fields.

Empno      Text
Name      Text
HireDate      Date/Time
TotalDays      Number      Computed
            Due:=@Abs(@Integer((HireDate -ToDate) / (60 * 60 * 24)));
            @If(HireDate="";0;Due)

I have created some documents and TotalDays works fine. Returns 1 if HireDate is 04/10/2004

I've created a view for Employee form. View is called Employee View | EMPV.

In the view, I've created columns for all the 4 fields. If I create a document, the view displays Empno, Name, HireDate but does not display the TotalDays. I struggled for a long time but couldn't get the solution. :(

Actually I need this view when an employee completes 1 month. Means when 30 appears in the TotalDays of the view, an agent triggers a notification to someone.

Or anyone has any other way to send a notification if the totaldays is 30. ??
ninteen83Asked:
Who is Participating?
 
Bozzie4IT ArchitectCommented:
Your design doesn't make much sense.  Like Sjef says, documents don't refresh themselves...

So change it.

Doing the calculations in the view is a possibilty, but very bad performance-wise.  Avoid all time functions in views, because they will cause the view to recalculate all the time (yes, also @today).

Make TotalDays an Computed When Composed field, and use an agent to compute the number of days left.  This will make your view much faster.  Add the same logic to the QuerySave event (or the QueryRecalc event), so when people change a document, the values change too.  

Agent :  schedule it daily, at 3 o'clock in the morning or something.  Use your formula:
SELECT form="YourFormHere";
FIELD TotalDays := @If(HireDate="";0; @Abs(@Integer((HireDate -@Today) / (60 * 60 * 24))) )

In the view, put TotalDays.

In the QuerySave, and QueryRecalc events, put the same formula, to update the documents whenever someone saves it.
FIELD TotalDays := @If(HireDate="";0; @Abs(@Integer((HireDate -@Today) / (60 * 60 * 24))) )

cheers,

Tom




0
 
Bozzie4IT ArchitectCommented:
What is ToDate ?

I don't understand what you are doing : is TotalDays a fixed number, or is it meant to change every day ('countdown') ?

Tom
0
 
ninteen83Author Commented:
ToDate   is   Date/Time,   Computed,   @Today
0
Cloud Class® Course: C++ 11 Fundamentals

This course will introduce you to C++ 11 and teach you about syntax fundamentals.

 
Sjef BosmanGroupware ConsultantCommented:
If you check the Document Properties, is the correct value for TotalDays in the Document? Do you have validation checks in the date fields, using @IsTime()?
0
 
ninteen83Author Commented:
Sorry Dear .. I didn't get your 1st point. I'm not using any validation in the date fields. TotalDays returns number and everyday it changes because of ToDate. In all the documents it works/appears but it does not appear in the view.
0
 
Sjef BosmanGroupware ConsultantCommented:
Eh? "... everyday it (TotalDays) changes ..."? Documents don't change by themselves. Only a person, either directly or by means of an agent, can change a document. Storing TotalDays is therefore more or less pointless, just like ToDate for it will contain the date when the document is last saved.

In the view, the number of days should be recomputed every time the view is reopened. This makes it a time-consuming view. You might better store the date of the next milestone in the document, and make a view sorted ascending on the milestone date. You can make an agent that walks through the first few documents of that view every day. The documents with a milestone that lies today or before today should be dealt with, and they should be given a new milestone date. The others will be handled automatically the next day.

About my first point: open the view with the documents, DON'T open the document but type Alt-Enter (or click File/Document Properties), the Properties box will open, go to the second tab, and find the TotalDays item there. At the right you can find its value. What is it?
0
 
p_parthaCommented:
When you open the document, do u see the value in TotalDays. If yes then you should be seeing the value in view also. Also, if you want u can store the 30 days from the HIREdate in one field when the document is created and check ur agent against this date, so that u can minimize the calcualtion

Hope i am clear here

Partha
0
 
HemanthaKumarCommented:
Use your formula in the TotalDays with little modification the TotalDays column

          @If(HireDate="";0; @Abs(@Integer((HireDate -@Today) / (60 * 60 * 24))) )

~Hemanth

 
0
 
ninteen83Author Commented:
sjef bosman

I have gone through the Document Properties from the view. All Fields are there except TotalDays .. :( yes TotalDays doesn't appear in the Document Properties if I open it from the view ..
0
 
ninteen83Author Commented:
p partha

it doesn't appear in the view at all .. you can check it from the following link

http://members.fortunecity.com/nadirshah/img2/notes.gif
0
 
Sjef BosmanGroupware ConsultantCommented:
If, as you say, TotalDays is NOT in the Document Properties as a field, AND the field appears in the form, AND it is really the same form you are using, then the field MUST be on the form as Computed for Display.

What about my other suggestion, did you try that?? The milestone-date stuff?

I checked the link, there's nothing there except for a nice gif. You have a more interesting URL? ;)

Sjef
0
 
ninteen83Author Commented:
Bozzie ! I have tried the exact what you suggested  .. but no luck :( .. TotalDays still doesn't appear in the view. I've changed TotalDays' type from Computed to Computed for Display, Computed when Composed even to Editable .. it works .. but doesn't appear in the view ...
0
 
Bozzie4IT ArchitectCommented:
When you change the type, you must run the agent to set the field values.  You can check if the TotalDays field is set, by using the Document Properties (ALT-Enter, and look to the field values).

cheers,

Tom
0
 
ninteen83Author Commented:
Now the totaldays is appearing in the view ..

Thanks Bozzie .. Thank you all guys ..
0
 
Sjef BosmanGroupware ConsultantCommented:
As Tom said earlier, your design still doesn't make much sense. There are many roads from A to B, but you're taking a short-cut you'll be regretting some day. I think you "jumped to a solution" without analysing the requirements completely. The fact that you ignored my well-meant remarks is understandable but it indicates to me that you're not thinking ahead. You're solving your current problem without realizing that you created future issues.

If I'm way off, pray forgive me, but if you'd like to discuss this further I'm happy to do so.

Sjef :)
0
 
ninteen83Author Commented:
SJef !

I was looking for a quick and easy solution. Ofcourse my design still doesn't make sense. A document doesn't change by itself. I really appreciate your efforts to solve this problem.

The problem is that I'm new to Lotus Notes therefore I couldn't get what was suggested by you. :O and I couldn't ask you to describe it step by step. :'(


Sincerely.
0
 
Sjef BosmanGroupware ConsultantCommented:
ninteen83,

> and I couldn't ask you to describe it step by step

Why not? Just the fact that you're new to Notes should be the most important motive to ask almost anything! That is, if you intend to learn a lot. You know these sayings:
1. "There are no stupid questions, only stupid answers"
2. "There's never time to do it right, but there is always time to do it over".

Do think of your design in you spare time, and don't hesitate to ask questions!

Sjef :)
0
 
Sjef BosmanGroupware ConsultantCommented:
0
 
Bozzie4IT ArchitectCommented:
"There are no stupid questions, only stupid people" :-)

Tom
0
 
Sjef BosmanGroupware ConsultantCommented:
LOL
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.