Solved

Update of the Detail Lines of a Shipment for "Shipped Qty" field with the Screen-Based SOAP API

  • 27 December 2021
  • 12 replies
  • 181 views

I  am trying to update the Shipment line detail with Screen Based SOAP API service.

The code is  executed but respective record not updated.

Following is the code snippet

 

var commandList = new List<Command>();                
             

                commandList.Add(new Key
                {
                    ObjectName = SO302000.Result.DocumentDetails.LineNbr.ObjectName,
                    FieldName = SO302000.Result.DocumentDetails.LineNbr.FieldName,
                    Value = LineNbr.Trim(),
                    Commit = true
                });

                commandList.Add(new Key
                {
                    ObjectName = SO302000.Result.DocumentDetails.ShipmentNbr.ObjectName,
                    FieldName = SO302000.Result.DocumentDetails.ShipmentNbr.FieldName,
                    Value = acushipmentNbr.Trim(),
                    Commit = true
                });


                commandList.Add(new Value { Value = shipmentLines.ShippedQty.ToString(), LinkedCommand = SO302000.Result.DocumentDetails.ShippedQty,IgnoreError=true, Commit = true });

SO302000Content[] SO302000Content = context.SO302000Submit(list.ToArray());
                if (SO302000Content.Length > 0)
                {
                    return true;
         
                }

icon

Best answer by Naveen Boga 29 December 2021, 16:27

View original

12 replies

Userlevel 7
Badge +12

Hi @sysuser113  After assigning the Shipped Qty, are you saving the document? Please confirm.

@Naveen B  I’m saving the document as below before submitting it.

 

   commandList.Add(new Value { Value = shipmentLines.ShippedQty.ToString(), LinkedCommand = SO302000.Result.DocumentDetails.ShippedQty,IgnoreError=true, Commit = true });

commandList.Add(SO302000.Result.Actions.Save);               

var list = commandList;

 SO302000Content[] SO302000Content = context.SO302000Submit(list.ToArray());

if (SO302000Content.Length > 0)
                {
                    return true;
                    //return Operation<string>.CreateFromOperationSucess(SO302000Content[0].ShipmentSummary.ShipmentNbr.Value.ToString());
                }

 

 

Userlevel 7
Badge +12

Hi @sysuser113  Hope you are updating the OPEN/HOLD statuses shipments only. Please confirm.

@Naveen B  Yes, its a ON HOLD record. Manually, I can update the “Shipped Qty”.

Userlevel 7
Badge +12

Hi @sysuser113  Can you please share the complete code, I can take a look and let you know if I found anything

@Naveen B  Thanks for reply. Following is the code.

Acumatica 2020 R1
Build 20.106.0005

 

        try
            { 
                var SO302000 = LoadAndSetSchemaSOShipment();
                
                var commandList = new List<Command>();

                commandList.Add(new Key
                {
                    ObjectName = SO302000.Result.DocumentDetails.LineNbr.ObjectName,
                    FieldName = SO302000.Result.DocumentDetails.LineNbr.FieldName,
                    Value = LineNbr.Trim(),
                    Commit = true
                });

                commandList.Add(new Key
                {
                    ObjectName = SO302000.Result.DocumentDetails.ShipmentNbr.ObjectName,
                    FieldName = SO302000.Result.DocumentDetails.ShipmentNbr.FieldName,
                    Value = acushipmentNbr.Trim(),
                    Commit = true
                });

                commandList.Add(new Value { Value = shipmentLines.ShippedQty.ToString(), LinkedCommand = SO302000.Result.DocumentDetails.ShippedQty,IgnoreError=true, Commit = true });

                commandList.Add(new Value { Value ="ABC", LinkedCommand = SO302000.Result.DocumentDetails.Description, IgnoreError = true, Commit = true });

                commandList.Add(SO302000.Result.Actions.Save);

                var list = commandList;

                SO302000Content[] SO302000Content = context.SO302000Submit(list.ToArray());
                if (SO302000Content.Length > 0)
                {
                    return true;
                    
                }
                return false;
            }
            catch (Exception ex)
            {
                throw ex;
            }

Userlevel 7
Badge +12

Hi @sysuser113   We have re-written the entire code and verified it is working great.

Please verify and confirm.

 

namespace _2021R2
{
class UpdateShipmentQty
{
Screen _context;
static void Main(string[] args)
{
var objUpdateShipmentQty = new UpdateShipmentQty();
objUpdateShipmentQty.Initial();


}
private bool Login()
{
_context = new Screen
{
CookieContainer = new System.Net.CookieContainer(),
Timeout = 1000000
};
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;



var lresult = _context.Login("UserID@TenantName", "Password");
return lresult.Code == ErrorCode.OK;
}



private void Initial()
{



try
{
Login();


var content = _context.SO302000GetSchema();
_context.SO302000Clear();

var commands = new List<Command>();

ReqParameter(content, ref commands);
commands.Add(content.Actions.Save);


commands.Add(content.ShipmentSummary.ShipmentNbr);

var orderResults = _context.SO302000Submit(commands.ToArray());

_context.Logout();
}
catch (Exception ex)
{

string s = ex.Message.ToString();
_context.Logout();
}
}
private static void ReqParameter(SO302000Content content, ref List<Command> cmds)
{
if (cmds == null) throw new ArgumentNullException("cmds");
cmds = new List<Command>
{



//Header Details

new Value { Value="Shipment",LinkedCommand = content.ShipmentSummary.Type,Commit=true},
new Value { Value="004103",LinkedCommand = content.ShipmentSummary.ShipmentNbr,Commit=true},


//Line Details
content.Details.ServiceCommands.RowNumber,
new Value { Value="1",LinkedCommand = content.Details.LineNbr,Commit=true},
new Value { Value="004103",LinkedCommand = content.Details.ShipmentNbr,Commit=true},

new Value { Value="4",LinkedCommand = content.Details.ShippedQty,Commit=true},

};
}
}
}

 

Userlevel 6
Badge +1

Just wanted to note that Screen Based SOAP API is outdated and it will be discontinued. I’m not sure what’s the version it’ll be deprecated.

 

The recommendation is to switch to Contract Based REST API.

@Naveen B - Thanks for the reply. I have implemented your code in  following format but it always update “Shipped Qty”  of first row of the Detail record, even we provide different LineNbr. 

(Shipment have multiple line items)

Please see my below  code snippet.

      

         try
            { 
                
                var commandList = new List<Command>();

                commandList.Add(new Value { Value = "Shipment", LinkedCommand = SO302000.Result.ShipmentSummary.Type, Commit = true });
                commandList.Add(new Value { Value = acushipmentNbr, LinkedCommand = SO302000.Result.ShipmentSummary.ShipmentNbr, Commit = true });
                
                commandList.Add(SO302000.Result.DocumentDetails.ServiceCommands.RowNumber);
                commandList.Add(new Value { Value = "4", LinkedCommand = SO302000.Result.DocumentDetails.LineNbr,Commit = true });
        commandList.Add(new Value { Value = acushipmentNbr, LinkedCommand = SO302000.Result.DocumentDetails.ShipmentNbr, Commit = true });
                commandList.Add(new Value { Value = shipmentLines.ShippedQty.ToString(), LinkedCommand = SO302000.Result.DocumentDetails.ShippedQty, Commit = true });
                commandList.Add(SO302000.Result.Actions.Save);
                commandList.Add(SO302000.Result.ShipmentSummary.ShipmentNbr);
                commandList.Add(SO302000.Result.DocumentDetails.LineNbr);
                var list = commandList;

                SO302000Content[] SO302000Content = context.SO302000Submit(list.ToArray());
                if (SO302000Content.Length > 0)
                {
                   // Return the Line Number to which the record gets updated
                    var result= SO302000Content[0].DocumentDetails.LineNbr.Value.ToString();
                    return true;
                    
                }
                return true;
            }
            catch (Exception ex)
            {
                throw ex;
            }

 

 

 

 

Userlevel 7
Badge +12

Hi @sysuser113  I have modified the code and now it is working for multiple line items as well.

Here is the code for your reference.

Also, as suggested by Dmitry, SOAP based APIs are out dated and will be discontinued in future versions. Better you can go with the REST API.

 

  private static void ReqParameter(SO302000Content content, ref List<Command> cmds)
{
if (cmds == null) throw new ArgumentNullException("cmds");
cmds = new List<Command>
{
//Header Details

new Key { Value = "='Shipment'", FieldName =
content.ShipmentSummary.Type.FieldName, ObjectName =
content.ShipmentSummary.Type.ObjectName },

new Key { Value = "='S00000058'", FieldName =
content.ShipmentSummary.ShipmentNbr.FieldName, ObjectName =
content.ShipmentSummary.ShipmentNbr.ObjectName },



//Line Details
new Key { Value = "='1'", FieldName =
content.Details.LineNbr.FieldName, ObjectName =
content.Details.LineNbr.ObjectName },


new Key { Value = "='S00000058'", FieldName =
content.Details.ShipmentNbr.FieldName, ObjectName =
content.Details.ShipmentNbr.ObjectName },


new Value { Value="2",LinkedCommand = content.Details.ShippedQty,Commit=true},
};
}

 

 

@Naveen B  Yes, we are planning to move for REST API soon. 

I have tried your code but in my case it is still update only first record of detail line item.

Please see my below code.

Acumatica 2020 R1

try
            {

                var commandList = new List<Command>();
                string acushipmentNbr="007110";
                string LineNbr="4";
                commandList.Add(new Key { Value = "='Shipment'", LinkedCommand = SO302000.Result.ShipmentSummary.Type });
                commandList.Add(new Key { Value = "='" + acushipmentNbr + "'", LinkedCommand = SO302000.Result.ShipmentSummary.ShipmentNbr });
                
                commandList.Add(new Key { Value = "='" + LineNbr + "'", LinkedCommand = SO302000.Result.DocumentDetails.LineNbr, Commit = true });
                commandList.Add(new Key { Value = "='" + acushipmentNbr + "'", LinkedCommand = SO302000.Result.DocumentDetails.ShipmentNbr, Commit = true });
                commandList.Add(new Value { Value = shipmentLines.ShippedQty.ToString(), LinkedCommand = SO302000.Result.DocumentDetails.ShippedQty, Commit = true });
                commandList.Add(SO302000.Result.Actions.Save);
                commandList.Add(SO302000.Result.ShipmentSummary.ShipmentNbr);
                commandList.Add(SO302000.Result.DocumentDetails.LineNbr);
                var list = commandList;
                SO302000Content[] SO302000Content = context.SO302000Submit(list.ToArray());
                if (SO302000Content.Length > 0)
                {
                    // Return the Line Number to which the record gets updated
                    var result = SO302000Content[0].DocumentDetails.LineNbr.Value.ToString();
                    return true;

                }
                return true;
            
            }
            catch (Exception ex)
            {
                throw ex;
            }

Userlevel 7
Badge +12

Hi @sysuser113  Not sure, what is the issue with the above code. I’m attaching complete code for your reference. I have verified this and it is working as expected.

using SOAP.SOAPNB;
using System;
using System.Collections.Generic;
using System.Net;

namespace _2021R2
{
class UpdateShipmentQty
{
Screen _context;
static void Main(string[] args)
{
var objUpdateShipmentQty = new UpdateShipmentQty();
objUpdateShipmentQty.Initial();


}
private bool Login()
{
_context = new Screen
{
CookieContainer = new System.Net.CookieContainer(),
Timeout = 1000000
};
System.Net.ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;



var lresult = _context.Login("admin@Company", "admin");
return lresult.Code == ErrorCode.OK;
}



private void Initial()
{
try
{
Login();


var content = _context.SO302000GetSchema();
_context.SO302000Clear();

var commands = new List<Command>();

ReqParameter(content, ref commands);
commands.Add(content.Actions.Save);


commands.Add(content.ShipmentSummary.ShipmentNbr);

var orderResults = _context.SO302000Submit(commands.ToArray());

_context.Logout();
}
catch (Exception ex)
{

string s = ex.Message.ToString();
_context.Logout();
}
}
private static void ReqParameter(SO302000Content content, ref List<Command> cmds)
{
if (cmds == null) throw new ArgumentNullException("cmds");
cmds = new List<Command>
{
//Header Details

new Key { Value = "='Shipment'", FieldName =
content.ShipmentSummary.Type.FieldName, ObjectName =
content.ShipmentSummary.Type.ObjectName },

new Key { Value = "='S00000058'", FieldName =
content.ShipmentSummary.ShipmentNbr.FieldName, ObjectName =
content.ShipmentSummary.ShipmentNbr.ObjectName },



//Line Details
new Key { Value = "='1'", FieldName =
content.Details.LineNbr.FieldName, ObjectName =
content.Details.LineNbr.ObjectName },


new Key { Value = "='S00000058'", FieldName =
content.Details.ShipmentNbr.FieldName, ObjectName =
content.Details.ShipmentNbr.ObjectName },


new Value { Value="2",LinkedCommand = content.Details.ShippedQty,Commit=true},
};
}
}
}

 

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2022  Acumatica, Inc. All rights reserved