Ytria
Login
Printer Friendly Version

Tips and Tricks

Secrets That Are Guaranteed To Save You Time

How to create a new field in documents with a formula

NOTE: Our ‘Tips and Tricks’ section has been superseded by the Ytria Tech Lab. Archived tips are still being kept here for reference purposes. Please check the Ytria Tech Lab frequently for all the latest tips, tricks and tutorials to help you get the most out of your Ytria toolkit.


Select any Notes database (email, personal address book, applications etc.) on your workspace, open scanEZ from the Notes client toolbar.

Select a set of documents, however you like (using checkboxes, or with a selection formula) and place them into a My Selection folder. Once your group of documents is created, select them all (by clicking on the My Selection folder) which enables the Diff button. Click the Diff button, which then displays all the fields available. Click the Create button, and instead of entering a value for all the fields click the @ button to apply a formula for each of the fields about to be created. Click OK to create the new field and automatically set it's value with a formula.

Using a formula to set a field for one document (or many) documents can be as simple or complex as you like. Just imagine the formulas you use in your forms or agents.

For example, the following formula used in a Diff will create a new number field named MyWeekNbYear and at the same time set the value for a field named MyWeekNb (FIELD xxx := yyy), this can all be done from an existing field MyDate, and using intermediate values.

REM "Compute the Week Number";
dtCurrentDate:=@Date(MyDate);
vFirstDay :=
@If(
@Weekday(dtCurrentDate) = 1;
@Adjust(dtCurrentDate;0;0;-6;0;0;0);
@Adjust(dtCurrentDate;0;0;(2-@Weekday(dtCurrentDate));0;0;0)
);
vSecondsPassed := vFirstDay - @TextToTime("01-01-" + @Text(@Year(vFirstDay)));
vWeekPassed := @Round(vSecondsPassed / (60 * 60 * 24 * 7));
WeekNb := @If(vWeekPassed != 52; vWeekPassed + 1; @Day(vFirstDay) <= 28; 53; 1);

FIELD MyWeekNb := WeekNb;
REM "Return the appropiate Year (related to the week number)";
@If( WeekNb=1&@Month(dtCurrentDate)=12;@Year(dtCurrentDate)+1;
WeekNb>=52&@Month(dtCurrentDate)=1;@Year(dtCurrentDate)-1;@Year(dtCurrentDate))

If the field MyWeekNb already exists in the document, you will be asked if you want to replace the existing value or skip the document each time or to skip them all. The formula can even have some calls to Profile Documents (@GetProfileField) or to Views (@DbColumn or @DbLookup); just as you would do when coding an agent.

Create a new field in many documents

 
Thousands of organizations use Ytria software for faster Notes development and better Domino administration
 

This website require JavaScript for full functionality.
Please enable JavaScript in your Web browser.