Acumatica OpenAPI无法通过交叉引用按条形码搜索库存项目。
创始人
2024-07-25 10:31:21
0

要通过交叉引用按条形码搜索库存项目,您可以使用Acumatica OpenAPI中的INItemXRef终结点。以下是一个代码示例,演示如何使用OpenAPI按条形码搜索库存项目:

using PX.Api;
using PX.Api.Models;
using PX.Common;
using System;
using System.Collections.Generic;

namespace AcumaticaOpenAPISample
{
    class Program
    {
        static void Main(string[] args)
        {
            var endpointUrl = "https://your-acumatica-instance.com/entity/Default/17.200.001";

            var screenName = "IN202500"; // 库存项目维护屏幕的名称
            var siteID = "YourSiteID"; // 站点ID
            var barcode = "YourBarcode"; // 要搜索的条形码

            using (var client = new ScreenApi(endpointUrl))
            {
                // 登录到Acumatica
                client.Login("your-username", "your-password");

                // 创建屏幕实例
                var screen = client.GetSchema(screenName);

                // 设置筛选器参数
                var filters = new List
                {
                    new Filter
                    {
                        Field = new Field
                        {
                            ObjectName = screenName,
                            FieldName = "InventoryItem.barCode"
                        },
                        Condition = FilterCondition.Equals,
                        Value = barcode
                    }
                };

                // 设置查询参数
                var parameters = new List
                {
                    new Value { Value = siteID, LinkedCommand = screen.PrimaryCommand, Commit = true },
                    new Value { Value = "true", LinkedCommand = screen.Actions["Search"].Primary }
                };

                // 运行屏幕操作
                var result = client.Submit(screen.Actions["Search"], parameters.ToArray(), filters.ToArray());

                // 处理结果
                if (result != null && result.Length > 0)
                {
                    // 获取库存项目的信息
                    var inventoryItem = result[0].LinkedCommandResult.ChildResults[0].Rows[0].Data;

                    // 输出库存项目信息
                    Console.WriteLine("Inventory Item ID: " + inventoryItem["InventoryItem.InventoryID"]);
                    Console.WriteLine("Inventory Item Description: " + inventoryItem["InventoryItem.Descr"]);
                    // 其他字段...

                    // 可以在这里进行其他操作,例如创建销售订单等

                }
                else
                {
                    Console.WriteLine("No inventory item found for the given barcode.");
                }

                // 注销
                client.Logout();
            }

            Console.ReadKey();
        }
    }
}

请确保将以下值替换为实际的值:

  • endpointUrl:您的Acumatica实例的URL和版本号。
  • screenName:库存项目维护屏幕的名称。
  • siteID:要搜索的库存项目所属的站点ID。
  • barcode:要搜索的条形码。

此代码示例使用Acumatica OpenAPI的屏幕操作和查询功能来搜索库存项目,并使用返回的结果进行后续操作。

相关内容

热门资讯

Android Studio ... 要解决Android Studio 4无法检测到Java代码,无法打开SDK管理器和设置的问题,可以...
安装tensorflow mo... 要安装tensorflow models object-detection软件包和pandas的每个...
安装了Laravelbackp... 检查是否创建了以下自定义文件并进行正确的配置config/backpack/base.phpconf...
安装了centos后会占用多少... 安装了CentOS后会占用多少内存取决于多个因素,例如安装的软件包、系统配置和运行的服务等。通常情况...
按照Laravel方式通过Pr... 在Laravel中,我们可以通过定义关系和使用查询构建器来选择模型。首先,我们需要定义Profile...
按照分类ID显示Django子... 在Django中,可以使用filter函数根据分类ID来筛选子类别。以下是一个示例代码:首先,假设你...
Android Studio ... 要给出包含代码示例的解决方法,我们可以使用Markdown语法来展示代码。下面是一个示例解决方案,其...
Android Retrofi... 问题描述:在使用Android Retrofit进行GET调用时,获取的响应为空,即使服务器返回了正...
Alexa技能在返回响应后出现... 在开发Alexa技能时,如果在返回响应后出现问题,可以按照以下步骤进行排查和解决。检查代码中的错误处...
Airflow Dag文件夹 ... 要忽略Airflow中的笔记本检查点,可以在DAG文件夹中使用以下代码示例:from airflow...