Domino Code Fragment

Code Name*
Changing field values during testing.
Date*
04/28/2024
Source (or email address if you prefer)*
Rlatulippe@romac.com
IP address:.3.21.233.41
Description*
Here are a quick set of agents that can help you when developing/testing/implementing an application. They allow you to specify a field at the view level and change it on selected documents.
Type*
Formula
Categories*
(Misc)
Implementation:
Required Client:
Server:
Limitations:
Comments:
This agent simply retrieves the stored information, converts the text to the appropriate type and assigns it to the field. Note that the use of @SetField means that we can only assign values to fields that exist. You'll have to write custom agents to create new fields.
Files/Graphics attachments (if applicable): Code:

Call the first agent "Fix Field". Make it shared (or private if you'd like), run from Actions menu, and run once.

ENVIRONMENT ChangeItemName := "";
ENVIRONMENT ChangeItemValue := "";
ENVIRONMENT ChangeItemType := "";
ItemName := @Prompt([OKCANCELEDIT];
"Fix Which Field?";
"Enter the name of the field you want to change:";
"");
@If(ItemName=""; @Return("");
"");
ItemValue := @Prompt([OKCANCELEDIT];
"Field Value";
"Enter the new value for the field: (separate lists with a semicolon)";
"");
ItemType := @Prompt([OKCANCELLIST];
"Field Type";
"Select the field type for this field: (if the value is null select \"text\")";
"text";
"text":"date-time":"number":"text list":"number-list":"date-time list");
@If(ItemType=""; @Return("");
"");
ENVIRONMENT ChangeItemName := ItemName;
ENVIRONMENT ChangeItemValue := ItemValue;
ENVIRONMENT ChangeItemType := ItemType;
@Command([ToolsRunMacro]; "(Fix Field for all selected)")


The agent above simply gathers information and stores it in environment variables. This does mean that you are limited in how much data you can store in the field. If you need something larger use a profile document instead.

Call the second agent "(Fix Field for all selected)". Make it shared (or private if Fix Field is private), run manually from Agent list, and run on selected documents.

SELECT @All;
ItemName := @Environment("ChangeItemName");
ItemValue := @Environment("ChangeItemValue");
ItemType := @Environment("ChangeItemType");
@If(ItemName=""; @Return(""); "");
ListValue := @If(@Contains(ItemType; "list"); @Explode(ItemValue; ";"); ItemValue);
ConvertedValue := @If(@Contains(ItemType; "date-time"); @TextToTime(ListValue);
@Contains(ItemType; "number"); @TextToNumber(ListValue);
ListValue);
@SetField(ItemName; ConvertedValue)