Search

Assorted Linkage

Current Terror Alert Level

ClustrMap

« PercentRem.com | Main| Delegate math revisited »

Magic Button

Category domino formula smarticon
For as long as I can remember (possibly 2001) I've always maintained some variation on a SmartIcon toolbar button that a former coworker called the "magic button": it allows new fields to be added to a document and existing fields to be overridden or deleted from the document, either while editing the document or while it's selected in a view. I've seen various approaches to this basic concept over the years, and each time I install Notes on another computer, I either consult the Google to find one I've used before or just reconstruct it from memory. It finally occurred to me that if I just posted the one I'm currently using here, not only would it be easier for me to find later, but some of you might find it useful as well. So here's the current incarnation of said magic button:

targetField := @Prompt([OkCancelEditCombo]; "Select Field"; "Select a field to override:"; ""; @DocFields );
updateTypes := "Text":"Number":"Time":"Delete Field";
updateType := @Prompt([OkCancelList]; "Select Type"; "Choose a type or action:"; "Text"; updateTypes );
@If(updateType = "Delete Field"; @Return(@SetField(targetField;@DeleteField)); "" );
newValue := @Prompt([OkCancelEdit];"New Value";"Enter the new value:"; @Text(@GetField(targetField )));
newTypeValue := @Select(@TextToNumber(@Replace(updateType; @Subset(updateTypes;3);"1":"2":"3" )); newValue; @TextToNumber(newValue); @TextToTime(newValue));
@SetField(targetField; newTypeValue)

I'm sure you can decipher the above, but here's what it does:
  1. Asks you which field you want to override. Type in a new one if you're adding a field. I've seen other versions where something like "---NEW---" is included in the field list prompt, and if you select that, it asks for the new field name... figured I might as well skip that extra step by just using [OkCancelEditCombo].
  2. Asks what data type the new value will be (text, number or time), with an option to delete the field instead - in which case the formula just deletes the field and exits.
  3. Asks what the new value will be, defaulting to the current value (if any).
  4. If the new value's data type is not text, converts the value to the selected type.
  5. Writes the new field value to the document.
This little button has saved me oodles of time over the years...

(cross-posted at BleedYellow)

Comments

Gravatar Image1 - I used to have a magic button, too. Now I just use NoteMan (for the past several years). It does much more than my magic button ever did.

On the specific topic of magic buttons, though, I trust you've seen Chad Smiley's work? { Link }

Gravatar Image2 - Good call... Chad's field editor is crazy cool, and I'd forgotten all about it. Thanks for the reminder!

Gravatar Image3 - Thanks!

Used to have two buttons for this, one for editing a field, and one for deleting a field.. Less is more.. :)

Gravatar Image4 - I have one of these too,and I keep a copy of the formula on a memory stick so that I can add it to any Notes client that needs it. Like most people, I stole mine from somewhere else, and tweaked it about a bit. It does the same as Tim's, just slightly differently. Funnily enough, on my last project, it was also referred to as the "Magic button". I also have the Ytria tools available when more serious action is required.

Gravatar Image5 - Next my wife complains about me finding her "magic button" I'm sending her to this article! (But not to you.)

Gravatar Image6 - (Just kidding.... I never have trouble finding it, of couse.)

Gravatar Image7 - Nice Buttons! Emoticon

Gravatar Image8 - Ok, you BleedYellow boys are apparently a WEE bit too close! Can we all agree to keep Nate's wife's "magic button" off limits?!? Yowza!

Post A Comment

:-D:-o:-p:-x:-(:-):-\:angry::cool::cry::emb::grin::huh::laugh::lips::rolleyes:;-)

Contact Me

Hire Me

Elsewhere

What the Quote?

"Imagine if the election came down to Alaska... they'd be runnin' out of their igloos."

Steven Rodgers

"It won't scan the monkey!"

Tim Tripcony

"Yeah, fight the power... be an exponent opponent."

Tim Tripcony

"You have Eddie Izzard in your pants?"

Dan Huddlestun

"It's hard to tell, when you have three legs."

Laura Tripcony

Apparel

Lotus Rocks

I write the code that makes the young girls cry