Avatar of abissa
abissaFlag for Switzerland asked on

Lotus Runs Formula Agent on Selected Documents

Hi to everyone,

Here's my problem: I have two database, one old and a new one created using old one's template.
In the new one, I have added several fields in the Request form.
I have to import a lot of documents from the old one to the newer one.
Copy/paste works fine, yet I have to update all those documents to integrate the new fields.

I created an Agent called "UpdateRequest" which uses Formula Language.
One of the formula is a DbLookup.
The agent works perfectly on a highlighten document when, as Target, I select "None", but fails if I select "Selected Documents" (Lotus prompts a message saying that certain @Functions cannot be used when "Selected Documents" is the agent's target chosen.

so, I want to create an agent in lotus script that runs for each selected document my "UpdateRequest" agent. I did but got the same error message (@Functions cannot be used....)

I have tried putting my formula language in a script agent. yet the Evaluate function fails. It works fine with formula like @Word, @Contains...yet it fails with the @DbLookup.

If someone knows either how to Evaluate the @DbLookup formula in lotus script, or how make the formula agent runs on Selected Documents, it would be appreciated!! (otherwise I will have to launch the agent manually on each document...more than 3000...no way!)

for information, my DbLookup is used to retrieve from the Domino Directory the mail server dpending of the user name (i.e for a specified user, check on which server we have registered him) - so basically my DbLookup returns the name of the mail server.

Okay, if you need more info do not hesitate to ask.

Thanks by advance to all of you!
Lotus IBM

Avatar of undefined
Last Comment
abissa

8/22/2022 - Mon
Sjef Bosman

What's the code you tried? In LotusScript?
ASKER CERTIFIED SOLUTION
olaraak

Log in or sign up to see answer
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform
Sign up - Free for 7 days
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
Not exactly the question you had in mind?
Sign up for an EE membership and get your own personalized solution. With an EE membership, you can ask unlimited troubleshooting, research, or opinion questions.
ask a question
ASKER
abissa

Okay, thxs for the answer, I've tried olaraak's code....and I can't make it work.

I think the dblookup doesn't work, which is odd as it works with the same settings using formula.
furthermore, each time I use retVal like that: retVal(0), I get the error message: "Variant does not contain a container"....note that I'm not very good with lotus dev....

And by the way, I use the RequesterName field of the doc to get the UserNA variable, which is the "Last Name , first Name" format use in the lotus directory to display documents name.

It goes like this:

      Dim sess As New NotesSession
      Dim db As NotesDatabase
      Dim collection As NotesDocumentCollection
      Dim doc As NotesDocument
      Dim UserNA As String
      Dim Temp As String
      Dim Temp2 As String
      Dim dblook As String
      Dim dblook2 As String      
      
      Set db = sess.CurrentDatabase
      Set collection = db.UnprocessedDocuments
      Set doc = collection.GetFirstDocument()
      
      Dim retVal As Variant
      
      While Not(doc Is Nothing)
            'Msgbox "Requester Name " +doc.RequesterName(0)
            Temp = Strtoken(doc.RequesterName(0)," ",2)
            Temp2 = Strtoken(doc.RequesterName(0)," ",1)
            UserNA = Temp + " , " + Temp2
            'Msgbox UserNA
            
        ' Use cached dblookup for performance gain
            Msgbox "before lookup"
            retVal = Evaluate ( {@dblookup ("Notes"; "Server_Name" : "names.nsf"; "People"; UserNA;"6")}, doc)
            If retVal ="Server1_Name" Then
                  Msgbox " server1"
            Else
                  If retVal ="Server2_Name" Then
                        Msgbox " server2"
                  Else
                        If retVal ="Server3_Name" Then
                              Msgbox " server3"
                        Else
                              Msgbox "DBLOOKUP FAILED"
                        End If
                  End If
            End If                          ' I always got DBLOOKUP failed!!!!
            
            Msgbox "After look up" + Cstr(retVal)            
            Msgbox "before assigment"
            'doc.UserLocation(0) = retVal(0)            -> get illegal use of properties
            'dblook = retVal(0)                                          -> variant does not contain a container
            'Msgbox retVal(0)                                          -> variant does not contain a container
            dblook = Cstr(retVal)                              '-> get empty string!
            Msgbox dblook
            
        ' insert server name in new field
       ' doc.server-name-field = retVal(0)
        '
        ' - fill the other field(s)
        '
            Call doc.Save(True,False) ' Save current doc
            
            Set doc = collection.GetNextDocument(doc)
      Wend

Okay, I hope it's clear enough. Thanks by advance for looking into this!

ciao
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
SOLUTION
Log in to continue reading
Log In
Sign up - Free for 7 days
Get an unlimited membership to EE for less than $4 a week.
Unlimited question asking, solutions, articles and more.
ASKER
abissa

Okay, so in the end I couldn't manage to make the thing run on all documents, yet I found a workaround with a formula agent, the dblookup working fine this way.
I haven't been able to make it work as you told, neither by looking at other issues on the site and testing solutions.
I guess the problem comes from somewhere else.
Any way, thanks for the answers.
This is the best money I have ever spent. I cannot not tell you how many times these folks have saved my bacon. I learn so much from the contributors.
rwheeler23