Axapta 基于重复值执行方法操作

Axapta 基于重复值执行方法操作,axapta,dynamics-ax-2012,x++,Axapta,Dynamics Ax 2012,X++,我有一个表,我正在其上创建一个方法,我希望基于来自2个字段的重复值运行操作 例如: 我有表A,其中包含以下字段: IncidentDescription Identifier 现在,我想基于以下条件在方法中运行某个操作: 如果同一表格中的另一行中已经存在IncidentDescription,但前提是标识符不同。(因此,如果仅存在一行IncidentDescription,则不会运行该操作) 我怎样才能解决这个问题?是否可以在if语句中实现这一点? 或者是否有可能/最好运行“while sel

我有一个表,我正在其上创建一个方法,我希望基于来自2个字段的重复值运行操作

例如:

我有
表A
,其中包含以下字段:

IncidentDescription
Identifier
现在,我想基于以下条件在方法中运行某个操作:

如果同一表格中的另一行中已经存在
IncidentDescription
,但前提是
标识符不同。(因此,如果仅存在一行IncidentDescription,则不会运行该操作)

我怎样才能解决这个问题?是否可以在
if语句中实现这一点?
或者是否有可能/最好运行“while select”查询,并(如果存在)基于计数结果(>1)运行计数方法

编辑:

我正在尝试创建查询,如下所示:

    select count (IncidentDescription) from TableA;
    {

// I am trying to convert the result, because it gives me the error: "Operand types are not compatible with the operator, i am not sure how to make this.
        serialCount = str2num(IncidentDescription);

    if (IncidentDescription > 1)
           //Action to go here;
    }

稍后我将生成标识符。

请使用以下代码作为提示,并根据您的要求进行修改:

TableA  tableA;
TableA  tableAJoin;
;

select firstOnly tableA
    join tableAJoin
        where tableA.IncidentDescription == tableAJoin.IncidentDescription 
           && tableA.Identifier          != tableAJoin.Identifier;

if (tableA.RecId)
{
    info(strFmt("%1 - %2", tableA.Identifier, tableA.IncidentDescription));
    info(strFmt("%1 - %2", tableAJoin.Identifier, tableAJoin.IncidentDescription));
}
如果需要检查表单数据源(其中tableA是数据源名称)上的
displayOption
方法,请按如下方式修改

public void displayOption(Common _record, FormRowDisplayOption _options)
{
    TableA  tableACurrent;
    TableA  tableALocal;
    ;

    tableACurrent = _record;

    select firstOnly RecId from tableALocal
        where tableALocal.IncidentDescription == tableACurrent.IncidentDescription 
           && tableALocal.Identifier          != tableACurrent.Identifier;

    if (tableALocal.Identifier)
    {
        //record has dublicates
        ...
    }

    super(_record, _options);
}

请使用以下代码作为提示,并根据您的要求进行修改:

TableA  tableA;
TableA  tableAJoin;
;

select firstOnly tableA
    join tableAJoin
        where tableA.IncidentDescription == tableAJoin.IncidentDescription 
           && tableA.Identifier          != tableAJoin.Identifier;

if (tableA.RecId)
{
    info(strFmt("%1 - %2", tableA.Identifier, tableA.IncidentDescription));
    info(strFmt("%1 - %2", tableAJoin.Identifier, tableAJoin.IncidentDescription));
}
如果需要检查表单数据源(其中tableA是数据源名称)上的
displayOption
方法,请按如下方式修改

public void displayOption(Common _record, FormRowDisplayOption _options)
{
    TableA  tableACurrent;
    TableA  tableALocal;
    ;

    tableACurrent = _record;

    select firstOnly RecId from tableALocal
        where tableALocal.IncidentDescription == tableACurrent.IncidentDescription 
           && tableALocal.Identifier          != tableACurrent.Identifier;

    if (tableALocal.Identifier)
    {
        //record has dublicates
        ...
    }

    super(_record, _options);
}

感谢您的帮助,当我添加此代码时,作为数据源中的一个显示选项,它显示的是所有相同的记录。有什么想法吗?谢谢你的帮助,当我添加这段代码时,作为我的数据源中的一个方法作为一个显示选项,它显示的是所有相同的记录。有什么想法吗?