Solved

LotusScript:  problem using Evaluate statement.

Posted on 2000-02-24
12
934 Views
Last Modified: 2013-12-18
I have a form with 6 fields, called
Approver_1
Approver_2
Approver_3
etc.

When I put test fields on the form I can see that

@Member(@UserName;Approver_1:Approver_2:Approver_3:Approver_4:Approver_5:Approver_6)

gives exactly the right results... ie if the user's name is Approver_3, then it returns "3".

I have an action button, behind which is various script including:

Dim Authorized As Variant
...
Authorized=Evaluate("@Member(@UserName;Approver_1:Approver_2:Approver_3:Approver_4:Approver_5:Approver_6)")

However, the Evaluate statement above doesn't work.  No matter what, I get Authorized(0) = 0.

What am I doing wrong??

...Pentapod
0
Comment
Question by:pentapod
  • 6
  • 6
12 Comments
 
LVL 6

Accepted Solution

by:
ghassan99 earned 50 total points
ID: 2556311
Follow this simple example:
Sub Click(Source As Button)
     Dim Authorized As Variant
     Dim ws As New notesuiworkspace
     Dim uid As notesuidocument
     Set uid = ws.currentdocument
     value = uid.fieldgettext("Approver1")
     stringeval = "@Member(@username;'" + value + "')"
     Authorized=Evaluate(stringeval)
     Messagebox authorized(0)
End Sub

-Gus
0
 
LVL 1

Author Comment

by:pentapod
ID: 2602238
OK, I changed the code to:

     Dim session As New NotesSession
     Dim ws As New notesuiworkspace    
     Dim db As NotesDatabase
     Dim uidoc As notesUIDocument
     Dim approverlist As String
     Dim Authorized As Variant

     Set uidoc=ws.currentDocument

Approverlist = uidoc.fieldgettext("approver_1") + ":" + uidoc.fieldgettext("approver_2") + ":" +uidoc.fieldgettext("approver_3") + ":" +uidoc.fieldgettext("approver_4") + ":" +uidoc.fieldgettext("approver_5") + ":" +uidoc.fieldgettext("approver_6")
         Authorized=Evaluate("@Member(@UserName;'"+ Approverlist +"')")

.... It doesn't give an error, but it still doesn't work.  I can see that Approverlist contains my hierarchical name, as well as others separated by :s, but Authorized(0) = 0.

Any thoughts?

....Pentapod
0
 
LVL 6

Expert Comment

by:ghassan99
ID: 2602677
Simply Pentapod,
The Approvelist is not a real LIST to Notes the way you created it.  Use this:

Authorized=Evaluate("@Member(@UserName; @Explode('" + Approvelist + "';':'))")

-Gus
0
 
LVL 1

Author Comment

by:pentapod
ID: 2602744
Do I need to change the creation of Approverlist?  Because it still isn't working... sigh...  :(

My Approverlist looks like this:

"Pentapod/BR/SPE:Fred Bloggs/BR/SPE:John Doe/UK/EU/SPE:::"

My @username is Pentapod/BR/SPE

....Pentapod
0
 
LVL 6

Expert Comment

by:ghassan99
ID: 2602758
@username returns the full heirarchical name, its not returning 'Pentapod/BR/SPE'!  Are you sure that 'Pentapod/BR/SPE' is stored in the field (in that exact syntax) on the form?  If it is then in the formula change from @username to @v3username.

-Gus
0
 
LVL 1

Author Comment

by:pentapod
ID: 2605413
Oh - you're right!

OK, using
     Authorized=Evaluate("@Member(@name([CN];@UserName); @Explode('" + Approvelist + "';':'))")

and changing Approverlist so that it uses CN format only, it still doesn't work though...

Maybe there's a better way of going about this.  All I want to know is how, using LotusScript, to tell whether the current user is one of the users listed in the fields on the form.

Pentapod

0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 6

Expert Comment

by:ghassan99
ID: 2606147
This is the simplest of ways!  Why you want to complicate things with script?

Just tell me whats the formula in the field, or give me a sample field value...the formula that fills approver_1 for instance.

-Gus
0
 
LVL 1

Author Comment

by:pentapod
ID: 2612276
There is a form that the user creates, to request equipment purchase.  The user fills in the equipment details and prices, and then lists the names of the approvers in the fields Approver_1, Approver_2, etc.  The number and names of the approvers vary depending on what equipment is being purchased and for who, so this information can't be fixed.

Then the user presses a "send to approvers" action button and the database sends an email to the first approver with a doclink.  The first approver goes to the document and clicks on an "approve" or "reject" action button at the top.

The Approve button has to: 1. check that the user who clicked it is one of the approvers listed;  2. stamp "approved" with the date and time if the user is an approver; 3. find the next approver (if there is one) and send an email with doclink; and 4. check to see if that was the last approver, and if so, change the status to "approved" and notify the initiator of the request.

Right now I have got it to work by doing it another way.

     approver(0) = uidoc.fieldGetText("Approver_1")
     approver(1) = uidoc.fieldGetText("Approver_2")
     approver(2) = uidoc.fieldGetText("Approver_3")
     approver(3) = uidoc.fieldGetText("Approver_4")
     approver(4) = uidoc.fieldGetText("Approver_5")
     approver(5) = uidoc.fieldGetText("Approver_6")
     
     For i = 0 To 5
          If currentuser(0) = approver(i) Then
               Authorized = 1
          End If
     Next


Still, it would be nice to know how to manipulate a list using script.

....Pentapod
0
 
LVL 6

Expert Comment

by:ghassan99
ID: 2612846
There is a whole section in the help file on Lists.  Its really simple, a list is associated with an array.  But when you get a value from the ui with fieldgettext, u will get a string value.  You should use the backend and u will capture the list in an array eg item=doc.approver_1, now item will be an array.  You can use a forall loop or a for loop to traverse the array.  For assigning, use doc.replaceitemvalue("approver_1",array).  Thats a short description.

-Gus
0
 
LVL 1

Author Comment

by:pentapod
ID: 2623752
Don't have time to try it at the moment, but I'm accepting your answer as I'll be travelling for the next 3 weeks.  I'll check it all out when I get back.  Anyway the database is working with the work-around so it's no longer urgent.  Thanks for the help,

Pentapod
0
 
LVL 1

Author Comment

by:pentapod
ID: 2623754
Don't have time to try it at the moment, but I'm accepting your answer as I'll be travelling for the next 3 weeks.  I'll check it all out when I get back.  Anyway the database is working with the work-around so it's no longer urgent.  Thanks for the help,

Pentapod
0
 
LVL 6

Expert Comment

by:ghassan99
ID: 2624523
Good luck

-Gus
0

Featured Post

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

For users on the Lotus Notes 8 Standard client, this article provides information on checking the Java Heap size and adjusting it to half of your system RAM in attempt to get the Lotus Notes 8.x Standard client to run faster.  I've had to exercise t…
Lack of Storage capacity is a common problem that exists in every field of life. Here we are taking the case of Lotus Notes Emails, as we all know that we are totally depend on e-communication i.e. Emails. This article is fully dedicated to resolvin…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

758 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now