How to use Acumatica Contract API to change stock item ID

0

I'd like to use the contract API to change the Inventory ID on items. It seems like I should be able to do this, but I think I'm missing how I send the new InventoryID to the invoked method.

I'm using a web service endpoint with the ChangeID method added. Under the parameters I added a parameter named key and mapped to CD (which is what the field is called in the dialog, and how it's used in a change project order example), but I'm not really clear on how I associate via the mapped object.

I've got this code:

       Dim strItemCode As String = "18r1"

        Dim TheItem As StockItem = soapClient.Get(New StockItem With {
                .InventoryID = New StringSearch With {.Value = strItemCode},
                .WarehouseDetails = New StockItemWarehouseDetail() {New StockItemWarehouseDetail With {.ReturnBehavior = ReturnBehavior.All}}})

        Dim TheInvokedResult As InvokeResult = soapClient.Invoke(TheItem, New ChangeID With {.key = New StringValue With {.Value = "18r1TJK"}})

It works up to the point that it does in fact load the item, but when I try the invoked result I get an error. The error seems like I might be passing the wrong parameters, which of course would make sense, but the docs have something tantalizingly close to this so I thought I would give it a whirl. Thanks in advance.

System.ServiceModel.FaultException
  HResult=0x80131501
  Message=System.ArgumentNullException: Value cannot be null.
Parameter name: key
   at PX.Api.ContractBased.Soap.WebApiSoapController.Post(ISoapSystemContract systemContract, XmlReader requestReader, String serviceNamespace, String internalNamespace, MethodInfo method, Func`1 serviceFactory, IEdmModel edmModel)
   at PX.Api.ContractBased.Soap.WebApiSoapController.<Post>d__8.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at PX.Api.ContractBased.Soap.WebApiSoapController.<Login>d__6.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Threading.Tasks.TaskHelpersExtensions.<CastToObject>d__3`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__0.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__0.MoveNext()
  Source=mscorlib
  StackTrace:
   at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
   at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
   at InventoryEditor.ServiceReference1.DefaultSoap.Invoke(Entity entity, Action action)
   at InventoryEditor.ServiceReference1.DefaultSoapClient.Invoke(Entity entity, Action action) in C:\Data Files\InventoryEditor\InventoryEditor\InventoryEditor\Connected Services\ServiceReference1\Reference.vb:line 65002
   at InventoryEditor.Form1.Button1_Click(Object sender, EventArgs e) in C:\Data Files\InventoryEditor\InventoryEditor\InventoryEditor\Form1.vb:line 24
   at System.Windows.Forms.Control.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnClick(EventArgs e)
   at System.Windows.Forms.Button.OnMouseUp(MouseEventArgs mevent)
   at System.Windows.Forms.Control.WmMouseUp(Message& m, MouseButtons button, Int32 clicks)
   at System.Windows.Forms.Control.WndProc(Message& m)
   at System.Windows.Forms.ButtonBase.WndProc(Message& m)
   at System.Windows.Forms.Button.WndProc(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m)
   at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
   at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
   at System.Windows.Forms.Application.ComponentManager.System.Windows.Forms.UnsafeNativeMethods.IMsoComponentManager.FPushMessageLoop(IntPtr dwComponentID, Int32 reason, Int32 pvLoopData)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
   at System.Windows.Forms.Application.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.OnRun()
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
   at InventoryEditor.My.MyApplication.Main(String[] Args) in :line 81
acumatica
asked on Stack Overflow Dec 17, 2019 by T-Rav

1 Answer

0

Well, turns out posting here was the inspiration I needed to find the answer. The trick is to use the "populate" when creating the WSE extension. You can then search for the dialog and it will populate the proper results into the parameters and boom, item code renaming.

answered on Stack Overflow Dec 18, 2019 by T-Rav

User contributions licensed under CC BY-SA 3.0