Evaluate in LotusScript/still got problems with is this lookup an error

Hi,Further to my other post:-

http://www-10.lotus.com/ldd/nd6forum.nsf/ShowMyTopicsAllFlatweb/132b842d045d695a85256fea006790ba?OpenDocument

I’ve given up with formula and decided to write a LotusScript agent to populate the SalesRep field…

This is to cover the case of the user working with a local copy, whereby lookups to the address book fails (it works fine when connected)…

I’m trying to use the ‘OnChange’ event to cover this, then it runs an agent called Prompt.

Unfortunately, my first Eval statement never seems to work. In fact, it doesn’t seem to get set to anything! (not even blank).

Any ideas? I’m really scratching my head here:-

Declarations

Dim ukpin As String

Dim Eval As Variant

Dim Eval2 As Variant

Main Code

Sub Initialize

Dim workspace As New NotesUIWorkspace

Dim response As Variant

Dim dialogBox As String

Dim userName As String

Dim uidoc As NotesUIDocument

Set uidoc = workspace.CurrentDocument

Dim Doc As NotesDocument

Set Doc =uidoc.Document

Dim Continue As Variant

If Doc.SalesRep(0) = "" Then

	continue = False

Else

	Dim SalesRep As Variant

	SalesRep = Doc.SPName

	Eval = Evaluate(|@DbLookup("":"";"85255F7E:006405B0";"($Users)";"| + doc.SPName(0) + |";"PIN")|,doc)

	'copied stuff

	'Eval = Evaluate(|@DbLookup( "": "NoCache" ; ""; "(Customer)";"| + doc.Comp(0) + |";14)|,doc)

	'Doc.QuoteType = Eval(0) 

	'end copied stuff

	

	Dim ukpin As String

	ukpin = Eval(0)

	

	Eval2 = Evaluate(|@IfError(@DbLookup("":"";"86256395:004EDFB0";"(PeopleByPin)";ukpin;"InternetAddress");"True")|)

	

'Dim Eval3 As Variant

'Eval3 = Evaluate(|@If(@IsError(Eval2); "True"; "False"|) 

	

	If Eval2(0) = "True" Then

		userName = "@companyname.com"

		dialogBox = "Please enter the Sales Persons internet email address"

		response = workspace.Prompt (PROMPT_OKCANCELEDIT, _

		"For example this address should end @companyname.com", _

		"Make changes here, if necessary, then click OK to continue or Cancel to quit.", _

		userName)

'If Isempty (response) Then

	'Messagebox  "Name not added.", , dialogBox

'Else

	'userName = response

	'Messagebox "Thank you, " + userName + ". Your name has been added.", , _

	'dialogBox

		doc.SPemail  = response

	Else

		doc.SPemail = Eval2

		

	End If

End If

End Sub

It’s driving me mad!

Subject: Evaluate in LotusScript/still got problems with is this lookup an error…

ukpin = Eval(0)

Eval2 = Evaluate(|@IfError(@DbLookup(“”:“”;“86256395:004EDFB0”;“(PeopleByPin)”;ukpin;“InternetAddress”);“True”)|)

Your “ukpin” in the eval is inside your quotes (|) ans so is not being resolved.

You could try …

Eval2 = Evaluate(|@IfError(@DbLookup(“”:“”;“86256395:004EDFB0”;“(PeopleByPin)”;
| + ukpin + |;“InternetAddress”);“True”)|)

Subject: RE: Evaluate in LotusScript/still got problems with is this lookup an error…

Use the debugger. Find out what the values of your variables are. In your original formula you used @Name([CN]…); does hte value you’re using as a key exactly match the document you want to look up? Eval will have some value in it, if the statement is executed at all. What value does it have? Sometimes you’re using fieldname SalesRep and sometimes SPName. Is that correct?

Subject: RE: Evaluate in LotusScript/still got problems with is this lookup an error…

In any case I fixed it now Dim SalesRep As Variant

	SalesRep = Doc.SPName(0)

	Eval = Evaluate(|@DbLookup("":"";"85255F7E:006405B0";"($Users)";"| + SalesRep+ |";"PIN")|,doc)

Subject: RE: Evaluate in LotusScript/still got problems with is this lookup an error…

Andre,I use the debugger extensively.

The problem is not that there is an error message, but that the Eval statement never gets a value returned.

I’ve actually written effectivly the exact same formula in @Formula language and it works fine…

Also, the only line that matters (the Eval), IS using the correct field name - this field converts the SalesRep to the common name - and it works…

Just wanted someone to check the Eval line is OK…