Sage MAS 90 and 200 Sage MAS 500 blogs Product Feedback Support Training
Reply
Contributor
vtsmike
Posts: 45
Registered: 04-01-2009
0
Accepted Solution

How to get Contact Name

I have the following snippet from VBScript that is being run from Customer Maint.

The results is '0' which I suspect is null.

I am trying to GET the full name from Customer Conacts, for the Main Contact, into variable contName

I tried  nGetValue for fields in AR_Customer too, and get '0'

Any ideas?

 

ARCustomer = oSS.nLookupTask("AR_Customer_ui")
retVAL = oSS.nSetProgram(ARCustomer)
Set oCustomer = oScript.NewObject("AR_Customer_svc", oSS)
Set oContact = oScript.NewObject("AR_CustomerContact_svc", oSS)

retVal = oContact.nSetKeyValue("ARDivisionNo$", "00")
retVal = oContact.nSetKeyValue("CustomerNo$", AR_Customer_bus_CustomerNo)
retVal = oContact.nSetKeyValue("ContactCode$", AR_Customer_bus_ContactCode)
retVal = oContact.nGetValue("ContactName$",contName)

 

Regular Contributor
Gator
Posts: 269
Registered: 12-05-2008

Re: How to get Contact Name

Looks like you need the following after you last SetKeyValue:

 

retVal = oContact.nFind()
Sage Employee
jepritch
Posts: 233
Registered: 08-25-2009
0

Re: How to get Contact Name

Hi vtsmike,

 

There are a couple of things I would do.

 

First in your script you need to tell the object you are finished setting the key, so after the last nSetKeyValue you have there, you need to do.

 

retVal = oContact.nFind() ' this tells the object to fire off the search for the key specified.

 

Secondly, I would initialize the contName variable as a string just above the nGetValue()

 

contName = "" ' declares as a string

 

Give this a try and hopefully it works for you.


Elliott

Contributor
vtsmike
Posts: 45
Registered: 04-01-2009
0

Re: How to get Contact Name

Both responses were technically correct, but Elliott did assume I had not declared/initialized contName and that was also required.

 

Thanks to both of you for SUPER QUICK responses (within minutes of posting)