Update fields without agents
Category None
Bookmark :
Bookmark :
Not sure what other people do when they want to quickly change or add a field value in a document, particularly in a production environment where it's generally not kosher to allow developers to create agents randomly. I know there are serious tools for doing this but I somehow seem to get away with using a simple toolbar icon which I've written over time. The other day I finally decided to finish it off properely so it supports date & number fields, and lists of values aswell.
Enjoy :-
REM {Smarticon Field Updater by Mark Demicoli};
REM {This formula will prompt you for a field name to add or edit in the currently selected document and is designed to run as a Smarticon in the Notes toolbar but should also work in other contexts.};
REM {Date fields are wrapped in square brackets, numbers prefixed by percent (%) and multiple values are delimited by semicolon.};
REM {When operating on lists, you can add entries by simply prefixing new entries with a semicolon};
t1 := @Prompt([OkCancelEdit]; "Enter Field Name"; ""; "");
@If(t1 = ""; @Return("");"");
t3 := "";
t2 := @GetField(t1);
@If(
@IsTime(t2[1]);
@For (n := 1; n <= @Elements(t2); n := n + 1;
t3 := @Trim(t3 : ("[" + @Text(t2[n]) + "]"))
);
@IsNumber(t2[1]);
@For (n := 1; n <= @Elements(t2); n := n + 1;
t3 := @Trim(t3 : ("%" + @Text(t2[n])))
);
@Do(
t3 := t2
));
editableText := @If(@Elements(t3) > 1; @Implode(t3; ";"); t3);
t2 := @Prompt([OkCancelEdit];"Edit value(s). Format: text, [Dates],%numbers, ; for multi"; "Modify field: " + @UpperCase(t1); editableText);
@If(
@LowerCase(t2) = "@deletefield" | @LowerCase(t2) = "@delete";
@Do(@SetField(t1; @Unavailable);@Return("")); "");
@If(@Left(t2; 1) = "[";
@Do(
t2 := @Trim(@Explode(t2; ";"));
@For (n := 1; n <= @Elements(t2); n := n + 1;
t4 := @If(t4 = ""; @TextToTime(@Right(@Left(t2[n]; "]"); "[")); t4 : @TextToTime(t2[n])))
); "");
@If(@Left(t2; 1) = "%";
@Do(
t2 := @Trim(@Explode(t2; ";"));
@For (n := 1; n <= @Elements(t2); n := n + 1;
t4 := @If(t4 = ""; @TextToNumber(@Right(t2[n]; "%")); t4 :@TextToNumber(@Right(t2[n]; "%"))))
); "");
t4 := @If(t4 = ""; @Explode(t2; ";"); t4);
@SetField(t1;t4)
REM {This formula will prompt you for a field name to add or edit in the currently selected document and is designed to run as a Smarticon in the Notes toolbar but should also work in other contexts.};
REM {Date fields are wrapped in square brackets, numbers prefixed by percent (%) and multiple values are delimited by semicolon.};
REM {When operating on lists, you can add entries by simply prefixing new entries with a semicolon};
t1 := @Prompt([OkCancelEdit]; "Enter Field Name"; ""; "");
@If(t1 = ""; @Return("");"");
t3 := "";
t2 := @GetField(t1);
@If(
@IsTime(t2[1]);
@For (n := 1; n <= @Elements(t2); n := n + 1;
t3 := @Trim(t3 : ("[" + @Text(t2[n]) + "]"))
);
@IsNumber(t2[1]);
@For (n := 1; n <= @Elements(t2); n := n + 1;
t3 := @Trim(t3 : ("%" + @Text(t2[n])))
);
@Do(
t3 := t2
));
editableText := @If(@Elements(t3) > 1; @Implode(t3; ";"); t3);
t2 := @Prompt([OkCancelEdit];"Edit value(s). Format: text, [Dates],%numbers, ; for multi"; "Modify field: " + @UpperCase(t1); editableText);
@If(
@LowerCase(t2) = "@deletefield" | @LowerCase(t2) = "@delete";
@Do(@SetField(t1; @Unavailable);@Return("")); "");
@If(@Left(t2; 1) = "[";
@Do(
t2 := @Trim(@Explode(t2; ";"));
@For (n := 1; n <= @Elements(t2); n := n + 1;
t4 := @If(t4 = ""; @TextToTime(@Right(@Left(t2[n]; "]"); "[")); t4 : @TextToTime(t2[n])))
); "");
@If(@Left(t2; 1) = "%";
@Do(
t2 := @Trim(@Explode(t2; ";"));
@For (n := 1; n <= @Elements(t2); n := n + 1;
t4 := @If(t4 = ""; @TextToNumber(@Right(t2[n]; "%")); t4 :@TextToNumber(@Right(t2[n]; "%"))))
); "");
t4 := @If(t4 = ""; @Explode(t2; ";"); t4);
@SetField(t1;t4)
-