Sage MAS 90 and 200 Sage MAS 500 blogs Product Feedback Support Training
Reply
Sage MAS 90 Customer
jasonitspyder
Posts: 108
Registered: 12-15-2010
0

Invalid/Unknown property name

[ Edited ]

Hi,

 

A little background: We are doing a lot of drop ships for our customers. So many of our invoices, even though billed to the same customer, but they were *shipped* to different addresses.

 

When making a replacement, MAS 200 will use the default BILL TO and SHIP TO address for that customer. So to save time copy n pasting addresses, I created a UDF to allow my customer service to enter an MAS invoice, and the script will search through the invoice record to get the SHIP TO address and automatically fill in the SHIP TO in the RMA creation module.

 

Long story short, I'm getting the "Invalid/unknown property name", Type Mismatch: oSession.AsObject (err/ret=2/0) when I tried this code:

 

Set oInvoiceHeader = oSession.AsObject(oSession.GetObject("AR_InvoiceHistoryInquiry_bus"))

 

 

To me, it sounds like the AR_InvoiceHistoryInquiry_bus is the one that's giving trouble, because I've tried replacing it with SO_SalesOrder_bus, and it went through fine.

 

If I want to search through invoice history records, is this AR_InvoiceHistoryInquiry_bus the one to use? Or am I just completely missed?

 

I'm very new to scripting, so thanks for reading through and your help.

 

Running MAS 200 4.4 PU4

 

 

Here's my preliminary code without any error checking:

 

invoiceNo = ""
address1 = ""
address2 = ""
address3 = ""
city = ""
state = ""
zip = ""
country = ""

retVal = oBusObj.GetValue("UDF_Invoice_No$", invoiceNo)

Set oInvoiceHeader = oSession.AsObject(oSession.GetObject("AR_InvoiceHistoryInquiry_bus"))

retVal = oInvoiceHeader.SetKeyValue("InvoiceNo$",invoiceNo)
retVal = oInvoiceHeader.SetKeyValue("HeaderSeqNo$","000000")
retVal = oInvoiceHeader.SetKey()

retVal = oInvoiceHeader.GetValue("ShipToAddress1$",address1)
retVal = oInvoiceHeader.GetValue("ShipToAddress2$",address2)
retVal = oInvoiceHeader.GetValue("ShipToAddress3$",address3)
retVal = oInvoiceHeader.GetValue("ShipToCity$",city)
retVal = oInvoiceHeader.GetValue("ShipToState$",state)
retVal = oInvoiceHeader.GetValue("ShipToZipCode$",zip)
retVal = oInvoiceHeader.GetValue("ShipToCountryCode$",country)

retVal = oBusObj.SetValue("ShipToAddress1$",address1)
retVal = oBusObj.SetValue("ShipToAddress2$",address2)
retVal = oBusObj.SetValue("ShipToAddress3$",address3)
retVal = oBusObj.SetValue("ShipToCity$",city)
retVal = oBusObj.SetValue("ShipToState$",state)
retVal = oBusObj.SetValue("ShipToZipCode$",zip)
retVal = oBusObj.SetValue("ShipToCountryCode$",country)

Sage Employee
jepritch
Posts: 233
Registered: 08-25-2009
0

Re: Invalid/Unknown property name

Hi Jason,

 

Your script looks okay, but there are a couple of things I would try and look at while debugging. 

 

#1) Since you are encountering the problem creating the object, try and break apart the creation linee, and do some checking.

 

oInvoiceHeader = 0

oInvoiceHeader = oSession.GetObject("AR_InvoiceHistoryInquiry_bus")

If oInvoiceHeader<>0 Then

   Set oInvoiceHeader = oSession.AsObject(oInvoiceHeader)

Else

   rVal = oScript.DebugPrint("Error creating object: " & oSession.LastErrorMsg) ' this error may point out things like you are not tracking history etc

End If

 

When you turn on the debugging trace, you should see this error message on the screen.  (Remember to "supress program trace")

 

#2) What I think is the problem is that this is an AR object that you are running from either S/O or R/A?  Sometimes when instantiating objects from a different module you MAY need to set the module first. 

 

retVal = oSession.SetModule("A/R")

 

#3) I would recommend since you are only reading from the history, that you use the _svc class, as this is a lighter weight class that doesn't have as much overhead.  Substitute, AR_InvoiceHistoryInquirty_svc.  You would have to tweek your script slightly, and replace the 'SetKey() with a 'Find(), as service (_svc) type classes do not support the SetKey() method.

 

Hope this helps

 

Elliott