Can I call a shared action via a formula?

Currently my lotus script is in querysave. The form has several action buttons that include a filesave, which calls querysave and so executes my code twice (once via the button and again on exiting the doc). This means msgboxes come up twice, etc.

I was thinking about pulling it out of querysave into a shared action or agent. It's a nuisance problem and not worth spending a ton of time on.

My impression is that I can't call a shared action via the formula language, so I have been looking at an agent. Can I just import my script functions into an agent and call it from within the action buttons on the form? Currently all my notes attributes are declared in querysave, will that "port" over to an agent? Or would I have to recode all that?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

First a word of warning...

If you want to ensure that a piece of code is executed when a document is saved, it needs to be placed in QuerySave or PostSave.  In other words, Save actions can be bypassed by using the menu "File \ Save", keyboard (CTRL-S), etc...

That said, sure, you can normally paste action code directly into the Initialize event of an agent.  Set the agent trigger to "Agent list selection" and the target to "None".  In your code get a handle to the current form using NotesUIWorkspace.CurrentDocument.

Regarding whether your QuerySave code will port over, it's hard to say.  It normally will, especially if you define the NotesUIWorkspace.CurrentDocument as 'Source'.  Remember, however, that you will loose the ability to prevent a save.  The Continue argument cannot be modified by an agent, only directly in QuerySave.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Lotus IBM

From novice to tech pro — start learning today.