Have you ever had one of your customers enter an incorrect value into a field and find you are unable to open the...
document due to that wrong field? Well this simple action will allow you to correct this problem in a view.
The steps are fairly simple. Create an action and call it what you would like. I use "Set a Value in Any Field" and set it to run manually from the Actions Menu. For the code use:
fname := @Prompt([OKCANCELEDIT]; "Enter Field Name"; "Enter the name of the field whose value you want to set. Note: This macro will only work if the field name is defined within the form."; "");
@If(fname = ""; @Return(0); "");
value := @Prompt([OKCANCELEDIT]; "Enter New Value"; "Enter the new value for this field. Leave blank to clear the value from the field"; "");
type := @If(value != "" & @Contains("0123456789.-"; @Left(value; 1));
@Prompt([OKCANCELLIST]; "Enter Data Type"; "What type of data is this?";
"Number"; "Date/Time" : "Number" : "Text"); "Text");
@PostedCommand([ToolsRunMacro]; "Set Value")
You will notice that it does call another agent called "Set Value."
This actually does the dirty work for you. This is the associated code for this agent:
value := @Environment("Temp1");
type := @Environment("Temp2");
@SetField(@Environment("Temp"); @If(value = ""; ""; type = "Number";
@TextToNumber(value); type = "Date/Time"; @TextToTime(value); value))
You can use this as a toolset available to you to correct an error in a document or to add to a database.