Replace any field value action

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");
@SetEnvironment("Temp"; fname);
@SetEnvironment("Temp1"; value);
@SetEnvironment("Temp2"; type);
@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.

This was first published in June 2001

There are Comments. Add yours.

TIP: Want to include a code block in your comment? Use <pre> or <code> tags around the desired text. Ex: <code>insert code</code>

REGISTER or login:

Forgot Password?
By submitting you agree to receive email from TechTarget and its partners. If you reside outside of the United States, you consent to having your personal data transferred to and processed in the United States. Privacy
Sort by: OldestNewest

Forgot Password?

No problem! Submit your e-mail address below. We'll send you an email containing your password.

Your password has been sent to:

Disclaimer: Our Tips Exchange is a forum for you to share technical advice and expertise with your peers and to learn from other enterprise IT professionals. TechTarget provides the infrastructure to facilitate this sharing of information. However, we cannot guarantee the accuracy or validity of the material submitted. You agree that your use of the Ask The Expert services and your reliance on any questions, answers, information or other materials received through this Web site is at your own risk.