Posting only - two handy agents for setting field values

For reference, here are two little handy agents you can use in any db to update a value of a field in all selected docs. The first agent prompts you for the field name, the new value, and if you want to replace the current value or append to it. If you’ve run it before, it doesn’t prompt you again, but just acts on the selected docs using the values you already supplied.

The second agent allows you to clear out the values you set in the first agent so you can start afresh.

First agent:

Name: SetField

Runtime Trigger: On Event, Action menu selection

Target: All selected documents

Formula:

@If(@Environment(“fld”)=“”;@SetEnvironment(“fld”;@Prompt([OkCancelEdit]; “Field”; “Enter the name of a field”; “”));“”);

@if(@Environment(“val”)=“”;@SetEnvironment(“val”;@Prompt([OkCancelEdit]; “Value”; “Enter the new value”; “”));“”);

@If(@Environment(“action”)=“”;@SetEnvironment(“action”;@Prompt([OkCancelList]; “Action”; “Enter”; “Replace”;“Replace”:“Append”));“”);

fld:=@Environment(“fld”);

val:=@Environment(“val”);

action:=@Environment(“action”);

@If(action=“Replace”;

@SetField(fld;val);

@SetField(fld;@GetField(fld) : val)

);

SELECT @All

Second agent:

Name: ResetSetField

Runtime Trigger: On Event, Action menu selection

Target: All selected documents

Formula:

@SetEnvironment(“fld”;“”);

@SetEnvironment(“val”;“”);

@SetEnvironment(“action”;“”);

SELECT @All

Subject: Posting only - two handy agents for setting field values

But have you seen this…

http://www.chadsmiley.com/EditDocumentFields

Subject: RE: Posting only - two handy agents for setting field values

I had not, and it looks robust. But does it always require a toolbar? That might limit it to just developer workstations.

Nevertheless, many thanks for the link.

I also like NotesFix for examining and changing field item.

Subject: RE: Posting only - two handy agents for setting field values

When I test this code I always test it as an agent, so there is no reason that you can not include the code in each application that it needs to be in.