1

I have a view selection formula:

Var :=@If(@IsAvailable(ENVIADO); @If(ENVIADO != "Sim"; "Valido";"");"Valido");
SELECT (Form="Documento"&@Date(Notes_data)>@Date(2013;3;31)&Emissor!=""&DocApagado="Não"&Estado="Definitivo"&@IsUnavailable($Conflict)) & Var = "Valido"

And I want it to select all documents from the past 7 days.excluding "today".

4

3 回答 3

1

Firstly, nobody will thank you for putting dates into a selection formula, as the view index has to be recreated every time the view is opened. It is much better to have a field in each document that will be either "y" or "n" depending on whether you want the document in this view. Then run an agent nightly to check which documents meet the criteria, and set the flag accordingly.

BUT, if you HAVE to have dates in your selection formula here's a suggestion (also, it helps to format the formula nicely to make it more readable). I'm presuming that "Notes_data" is the relevant field.:

Var :=@If(@IsAvailable(ENVIADO); @If(ENVIADO != "Sim"; "Valido";"");"Valido");
SELECT (
Form="Documento" &
@Date(Notes_data) < @Today &
@Date(Notes_data) > @Adjust(@Today(0;-8;0;0;0;0)) &
Emissor!="" &
DocApagado="Não" &
Estado="Definitivo" &
@IsUnavailable($Conflict)
) & 
Var = "Valido"

But, as I said before. Please don't do it this way.

于 2013-04-19T16:07:01.590 回答
1

我的方法是在视图的 postOpen 和 queryClose 事件中使用 @SetViewInfo([SETVIEWFILTER]; 。为此,请将选择公式更改为:

Var := @If(@IsAvailable(ENVIADO); @If(ENVIADO != "Sim"; "Valido";"");"Valido");
SELECT (Form="Documento" & Emissor!="" & DocApagado="Não" &
        Estado="Definitivo" & @IsUnavailable($Conflict) ) & 
       Var = "Valido"

接下来在视图的开头添加一列,该列已排序和分类。给它这个公式:

out := "";
@For(i:=1; i<7; i:=i+1;
    wrkDt := @Adjust(Notes_Data; 0; 0; (i*-1); 0; 0;0);
    tmp1 := @Text(@Year(@Date(wrkDt))) +
        "-" + @Right("00" + @Text(@Month(wrkDt));2) +
        "-" + @Right("00" + @Text(@Day(wrkDt));2);
    out := @Trim(out : tmp1)
);
out

这将导致您希望在给定日期显示的每个文档都出现在您希望它出现的每个日期的视图的七个类别中。

如果这是一个 Web 应用程序,您可以使用 RestrictToCategory 设置仅显示今天的文档。如果这是 Notes 客户端应用程序,请将 View 的 PostOpen 事件更改为运行公式代码并将其设置为:view 为

tmp1 := @Text(@Year(@Today)) +
        "-" + @Right("00" + @Text(@Month(@Today));2) +
        "-" + @Right("00" + @Text(@Day(@Today));2);
@SetViewInfo([SetViewFilter]; tmp1);

现在,当您打开视图时,您只会看到今天的文档。并且它不会经常需要刷新。

注意:我使用这种文本格式来确保即使服务器和客户端使用不同的格式,这对于任何本地日期显示格式都一样有效。

一个警告...... SetViewInfo 对当前数据库中的所有视图保持有效,因此您应该向除此之外的视图的所有 PostOpen 事件添加一个清除值的公式:

@SetViewInfo([SetViewFilter]; "");

快乐编码

/新人

于 2013-04-20T14:30:58.683 回答
0

天:=(@Today - @created)/86400;

它将返回从今天开始的天数和文档的创建日期。你可以给条件取决于你的要求。

于 2013-04-22T06:20:34.490 回答