Sage MAS 90 and 200 Sage MAS 500 blogs Product Feedback Support Training
Reply
Sage MAS 90 Customer
mroman98
Posts: 152
Registered: 04-05-2010
0
Accepted Solution

Populate an Alias Item UDF in sales orer entry

Hi Forum,

 

I have aUDF in the Alias Item Maintenance and and another one in Sales Order entry.

What i need to do is, populate the S/O entry UDF when the Item entered has an Alias...

Any sample out there that i can look at?

 

Regards,

Manuel Roman

 

Providex Developer
Moderator
Natasha
Posts: 180
Registered: 07-15-2009
0

Re: Populate an Alias Item UDF in sales orer entry

[ Edited ]

Manuel,

 

 I don't have sample code but this is what I would try:

 

In ItemCode;PostValidate, instantiate the IM_AliasItem_Svc object. 

Pass ItemCode into SetBrowseFilter method. 

Then use MoveFirst and MoveNext to find the right alias item record and get the alias item UDF.

If record found, set the Sales Order Detail UDF.

 

 

 

 

Natasha Chang
Sr. Software Engineer
Sage 100 ERP
Sage MAS 90 Customer
mroman98
Posts: 152
Registered: 04-05-2010
0

Re: Populate an Alias Item UDF in sales orer entry

Thanks Natasha i'll give it a try..

 

Regards,

Manuel Roman

Providex Developer
Sage MAS 90 Customer
mroman98
Posts: 152
Registered: 04-05-2010
0

Re: Populate an Alias Item UDF in sales orer entry

Hi Natasha,

 

I've tried the following and i am getting an error message when entring the line is S/O entry.

This is the coded that i am using...

 

retVal = oBusObj.GetValue("AliasItemNo$",UDFAlias)
retVal = oBusObj.GetValue("ItemCode$",Itemcode)


if UDFAlias <> ""  then
 ' Update UDF Alias Field
 Set oIMAliasObj = oSession.AsObject(oSession.GetObject("IM_ALIAS_ITEM_svc"))
 Set oSODtlObj = oSession.AsObject(oSOHdrObj.Lines)
 

 retVal = oIMAliasObj.SetKey(Itemcode)
 FoundLine = 0
 retVal = oIMAliasObj.SetBrowseFilter(ItemCode)
 retVal = oIMAliasObj.MoveFirst()
 Do Until CBool(oIMAliasObj.EOF) or FoundLine=1
  retVal = oIMAliasObj.GetValue("AliasItemNo$",AliasItemCode)
  retVal = oIMAliasObj.GetValue("UDF_ALIAS_DESCRIPTION_2$",IMAliasDesc)
  
  if AliasItemCode = UDFAlias  then
   FoundLine = 1
  end if
  if FoundLine <> 1 then
   retVal = oIMAliasObj.MoveNext()
  end if
 Loop

 If FoundLine then
  retVal = oSODtlObj.SetValue("UDF_ALIAS_DESCRIPTION_2$","Testing")
  
 end if

end if

 

REgards,

Manuel Roman

Providex Developer
Sage MAS 90 Customer
mroman98
Posts: 152
Registered: 04-05-2010
0

Re: Populate an Alias Item UDF in sales orer entry

Hi Forum,

 

This is the code that i  am using:

 

retVal = oBusObj.GetValue("AliasItemNo$",UDFAlias)
retVal = oBusObj.GetValue("ItemCode$",Itemcode)


if UDFAlias <> ""  then
 ' Update UDF Alias Field
 Set oIMAliasObj = oSession.AsObject(oSession.GetObject("IM_ALIAS_ITEM_svc"))
 Set oSOHdrObj = oSession.AsObject(oSession.GetObject("SO_SalesOrder_bus"))
 Set oSODtlObj = oSession.AsObject(oSOHdrObj.Lines)
 

 retVal = oIMAliasObj.SetKey(Itemcode)
 FoundLine = 0
 retVal = oIMAliasObj.SetBrowseFilter(ItemCode)
 retVal = oIMAliasObj.MoveFirst()
 Do Until CBool(oIMAliasObj.EOF) or FoundLine=1
  retVal = oIMAliasObj.GetValue("AliasItemNo$",AliasItemCode)
  retVal = oIMAliasObj.GetValue("UDF_ALIAS_DESCRIPTION_2$",IMAliasDesc)
  
  if AliasItemCode = UDFAlias  then
   FoundLine = 1
  end if
  if FoundLine <> 1 then
   retVal = oIMAliasObj.MoveNext()
  end if
 Loop

 If FoundLine then
  retVal = oSODtlObj.SetValue("UDF_ALIAS_DESCRIPTION_2$",IMAliasDesc)
  
 end if

end if

 

The Error that i am getting is:

 

err=26 pgm=Sy_Service_pvc line=1395

 

Regards,

Manuel Roman

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

Re: Populate an Alias Item UDF in sales orer entry

Hi Manuel,

 

Just at first glance, there are a couple of things I noticed in your script. 

 

1) You cannot use the SetKey() method with a _svc (Service object), you can try using Find() instead.  Although, it looks like you really don't need this line in your script.

 

2) Make sure you declare your variables, because depending on what your ItemCode or Alias is VB might mistake it for a numeric.  So your variables like UDFAlias, ItemCode, AliasItemCode, IMAliasDesc, should be declared as strings before they are used. (This is most likely the cause of your error)

 

3) Also, I don't think you need to have a separate object reference to the SalesOrderDetail object as if you are using this in the Post-Validate of the Item Code oBusObj should be the same object.

 

Hope this helps

Elliott

 

 

 

Sage MAS 90 Customer
mroman98
Posts: 152
Registered: 04-05-2010
0

Re: Populate an Alias Item UDF in sales orer entry

Thanks Elliott,

 

i changed the script to the following:

 

UDFAlias = ""
Itemcode = ""
AliasItemCode = ""
IMAliasDesc = ""

 

retVal = oBusObj.GetValue("AliasItemNo$",UDFAlias)
retVal = oBusObj.GetValue("ItemCode$",Itemcode)


if UDFAlias <> ""  then
 ' Update UDF Alias Field
 Set oIMAliasObj = oSession.AsObject(oSession.GetObject("IM_ALIAS_ITEM_svc"))
 
 FoundLine = 0
 retVal = oIMAliasObj.SetBrowseFilter(ItemCode)
 retVal = oIMAliasObj.MoveFirst()
 Do Until CBool(oIMAliasObj.EOF) or FoundLine=1
  retVal = oIMAliasObj.GetValue("AliasItemNo$",AliasItemCode)
  retVal = oIMAliasObj.GetValue("UDF_ALIAS_DESCRIPTION_2$",IMAliasDesc)
  
  if AliasItemCode = UDFAlias  then
   FoundLine = 1
  end if
  if FoundLine <> 1 then
   retVal = oIMAliasObj.MoveNext()
  end if
 Loop

 If FoundLine then
  retVal = oBusObj.SetValue("UDF_ALIAS_DESCRIPTION_2$",IMAliasDesc)
  
 end if

end if

 

 

And now i am getting an error 88

Type Mismatch : o.Seesion.AsObject(err/ret=2/0)

 

Regards,

Manuel Roman

 

 

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

Re: Populate an Alias Item UDF in sales orer entry

Manuel,

 

Sorry, I think I missed this before.  I believe the name of the service object you are trying to use should be IM_AliasItem_svc NOT IM_Alias_Item_svc.

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

Re: Populate an Alias Item UDF in sales orer entry

Just adding that the use of oScript.DebugPrint can be very useful when debugging these scripts.  Putting a few of these in your script can let you know values of variables within your script.

 

rVal = oScript.DebugPrint("ItemCode = " & ItemCode)

 

Or just to know where you are in the script, so if an error comes up you know if you gotten to a certain point.

 

rVal = oScript.DebugPrint("After SetBrowseFilter()")

 

Something like that.

 

 

Sage MAS 90 Customer
mroman98
Posts: 152
Registered: 04-05-2010
0

Re: Populate an Alias Item UDF in sales orer entry

Thanks Elliott,

 

This worked. I went back to see the name of the _svc and i didn't catch it.

Thanks for the prompt response.

 

Regards,

Manuel Roman

Providex Developer