在网格中填充字段并选择另一个字段 [英] Populate Field in Grid with selection of another Field

查看:226
本文介绍了在网格中填充字段并选择另一个字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这特别适用于Acumatica的服务管理模块。在服务订单屏幕(SD300100)和人工标签下。我们希望在创建新行并选择型号后,根据所选型号自动填充服务ID。



我已经编码:

  protected void FSSODetService_ServiceID_FieldSelecting(PXCache cache ,PXFieldSelectingEventArgs e)
{

var service =(FSSODetService)e.Row;
if(service == null)return;
var equipment =(FSEquipment)PXSelect< FSEquipment,
where< FSEquipment.SMEquipmentID,Equal< Required< FSSODetService.SMEquipmentID>>>> .Select(Base,service.ServiceID);
if(equipment!= null)
{
e.ReturnValue = equipment.EquipmentTypeID;




$ b $ p
$ b

这会在发布时给我这个错误。 p>

  \App_RuntimeCode\ServiceOrderEntry.cs(54):错误CS0118:'FieldService.ServiceDispatch.FSEquipment.SMEquipmentID'是'属性'但用于'类型'
\App_RuntimeCode\ServiceOrderEntry.cs(54):错误CS0118:'FieldService.ServiceDispatch.FSSODet.SMEquipmentID'是一个'属性',但像'type'一样使用

我觉得这与设置数据库值有关,因为它们是开始而不是小写。如果有人对此有所了解,我将不胜感激。

解决方案

以大写字母开头的字段名称引用属性值字段。
以小写字母开头的字段名称引用该字段的类型。



在BQL查询中,不提供字段的值给查询。您提供字段的类型,因此您必须使用小写的第一个字母:

  PXSelect< FSEquipment,
Where< FSEquipment.sMEquipmentID,Equal< Required< FSSODetService.sMEquipmentID>>>>

在BQL查询参数中,您使用属性值而不是类型,因此您使用大写字母:

  .Select(Base,service.ServiceID)

编辑:
您在FieldService产品的命名约定中发现了一个错误。
而不是像第一个字母大写/小写那样:'smequipmentID'/'SMEquipmentID'

  public abstract class sMEquipmentID:PX.Data.IBqlField {} 
public virtual int? SMEquipmentID {get;组; }

他们选了第三个字母:'SMequipmentID'/'SMEquipmentID'

  public abstract class SMequipmentID:PX.Data.IBqlField {} 
public virtual int? SMEquipmentID {get;组; }

所以对于这个字段(而不是所有其他的字段),您应该使用小写的第三个字母如果您无法访问源代码,则仍然可以使用Visual Studio或其他实用程序(如ILSpy)打开ServiceDispatch.DLL来搜索BQL查询中的'SMequipmentID'。

并检查类型名称。由于ServiceDispatch最初并不是Acumatica核心产品的一部分,它还有一些其他的命名约定差异:


This specifically pertains to the Service Management module of Acumatica. On the Service Orders screen (SD300100) and under the Labor Tab. We would like when a new row is created and a Model Number is selected then the Service ID would automatically be populated based on what model number that is selected.

I have coded this:

protected void FSSODetService_ServiceID_FieldSelecting(PXCache cache, PXFieldSelectingEventArgs e)
    {

        var service = (FSSODetService)e.Row;
        if (service == null) return;
        var equipment = (FSEquipment)PXSelect<FSEquipment,
        Where<FSEquipment.SMEquipmentID, Equal<Required<FSSODetService.SMEquipmentID>>>>.Select(Base, service.ServiceID);
        if (equipment != null)
        {
            e.ReturnValue = equipment.EquipmentTypeID;
        }
    }

This is leaving me this error when published.

\App_RuntimeCode\ServiceOrderEntry.cs(54): error CS0118: 'FieldService.ServiceDispatch.FSEquipment.SMEquipmentID' is a 'property' but is used like a 'type'
\App_RuntimeCode\ServiceOrderEntry.cs(54): error CS0118: 'FieldService.ServiceDispatch.FSSODet.SMEquipmentID' is a 'property' but is used like a 'type'

I feel like it has something to do with the setup of the Database values as they are capital in the beginning instead of lowercase. If any one has some knowledge about this, I would greatly appreciate it.

解决方案

Field name that start with a capital letter reference the property value field. Field name that start with a lower letter reference the type of the field.

In BQL query, you don't provide the values of the field to the query. You provide the type of the field so you have to use lowercase first letter:

PXSelect<FSEquipment,
Where<FSEquipment.sMEquipmentID, Equal<Required<FSSODetService.sMEquipmentID>>>>

In BQL query parameters you use the property value instead of the type so you use capital letter:

.Select(Base, service.ServiceID)

EDIT: You found a bug in the naming convention for the FieldService product. Instead of making the first letter upper/lower case like that: 'sMEquipmentID' / 'SMEquipmentID'

public abstract class sMEquipmentID : PX.Data.IBqlField { }
public virtual int? SMEquipmentID { get; set; }

They picked the third letter: 'SMequipmentID' / 'SMEquipmentID'

public abstract class SMequipmentID : PX.Data.IBqlField { }
public virtual int? SMEquipmentID { get; set; }

So for this field only (and not all the other ones) you should use the lowercase third letter 'SMequipmentID' in the BQL query.

If you have no access to source code, you can still open the ServiceDispatch.DLL with visual studio or other utilities like ILSpy to search and inspect the type names. Since ServiceDispatch wasn't originally a part of the core Acumatica product it does have a few other naming convention differences:

这篇关于在网格中填充字段并选择另一个字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆