Axapta 显示方法客户名称
我用不同的字段创建了一个新表,其中1个字段是Axapta 显示方法客户名称,axapta,dynamics-ax-2012,Axapta,Dynamics Ax 2012,我用不同的字段创建了一个新表,其中1个字段是CustAccount,我想在CustAccount下创建一列,显示CustName 我想根据客户帐户的选择显示客户名称 我已尝试在表CustTable上使用现有方法name,其中包含以下代码: display CustName name() { DirPartyTable dirPartyTable; CustName custName; boolean isSet = false;
CustAccount
,我想在CustAccount
下创建一列,显示CustName
我想根据客户帐户的选择显示客户名称
我已尝试在表CustTable
上使用现有方法name
,其中包含以下代码:
display CustName name()
{
DirPartyTable dirPartyTable;
CustName custName;
boolean isSet = false;
try
{
if (this.hasRelatedTable(identifierStr(DirPartyTable_FK)))
{
dirPartyTable = this.relatedTable(identifierStr(DirPartyTable_FK)) as DirPartyTable;
//Check to make sure the fields we are accessing are selected.
if (dirPartyTable && dirPartyTable.isFieldDataRetrieved(fieldStr(DirPartyTable, Name)))
{
custName = dirPartyTable.Name;
isSet = true;
}
}
}
catch (Exception::Error)
{
isSet = false;
}
//If we aren't joined to DirPartyTable or it isn't selected, then do a query to get it.
if(!isSet)
{
custName = DirPartyTable::getName(this.Party);
}
return custName;
}
这将显示客户名称,但不基于客户帐户选择。我正在考虑将代码复制到新表上的新方法。我如何编辑代码来实现这一点
或者有更好的方法吗?是的,这种方法Name()
效果很好。还有其他方法
我有两种方法可以满足您的需求:
CustTable CustTable;
AccountNum pCust;
str cName;
DirPartyTable DirPartyTable;
;
//First option
pCust = "YourCustomer";
Select * from CustTable where CustTable.AccountNum == pCust;
cName = CustTable.name(); //Get Name
//First option END
//Second option
pCust = "YourCustomer";
Select Party from CustTable where CustTable.AccountNum == pCust
join DirPartyTable where DirPartyTable.RecId == CustTable.Party;
cName = DirPartyTable.Name; //Get Name
//Second option END
是的,此方法Name()
工作正常。还有其他方法
我有两种方法可以满足您的需求:
CustTable CustTable;
AccountNum pCust;
str cName;
DirPartyTable DirPartyTable;
;
//First option
pCust = "YourCustomer";
Select * from CustTable where CustTable.AccountNum == pCust;
cName = CustTable.name(); //Get Name
//First option END
//Second option
pCust = "YourCustomer";
Select Party from CustTable where CustTable.AccountNum == pCust
join DirPartyTable where DirPartyTable.RecId == CustTable.Party;
cName = DirPartyTable.Name; //Get Name
//Second option END
您不想将该方法复制到表中。相反,请将此方法放在表中以引用:
// BP deviation documented
display CustName name()
{
return CustTable::find(this.CustAcccount).name();
}
您不想将该方法复制到表中。相反,请将此方法放在表中以引用:
// BP deviation documented
display CustName name()
{
return CustTable::find(this.CustAcccount).name();
}
为什么要使用
SqlParameters
表来存储AccountNum
条件的值?您好,因为如果使用简单的str变量,会出现运行时错误。关于。使用AccountNum
扩展数据类型来定义变量而不是任意的表字段不是更有意义吗?或使用str[20]pCust代码>?也许吧。解决方案是相同的,如果您更喜欢使用AccountNum
Extended数据类型,它也是正确的。但是如果你声明一个变量,比如str[20]pCust代码>你得到一个错误。语法错误。很抱歉,我是从内存中编写的,它与数组声明混淆了。第二部分应该是str20pcust代码>不带括号。我的观点是,虽然这三种解决方案都能工作,但我更喜欢使用AccountNum
扩展数据类型的解决方案,因为它可以生成最清晰可读的代码。如果我在生产代码中看到您的解决方案,我会非常困惑,因为我想知道为什么要使用SqlParameters
表。与代码的其余部分没有任何连接。为什么要使用SqlParameters
表来存储AccountNum
条件的值?您好,因为如果使用简单的str变量,会出现运行时错误。关于。使用AccountNum
扩展数据类型来定义变量而不是任意的表字段不是更有意义吗?或使用str[20]pCust代码>?也许吧。解决方案是相同的,如果您更喜欢使用AccountNum
Extended数据类型,它也是正确的。但是如果你声明一个变量,比如str[20]pCust代码>你得到一个错误。语法错误。很抱歉,我是从内存中编写的,它与数组声明混淆了。第二部分应该是str20pcust代码>不带括号。我的观点是,虽然这三种解决方案都能工作,但我更喜欢使用AccountNum
扩展数据类型的解决方案,因为它可以生成最清晰可读的代码。如果我在生产代码中看到您的解决方案,我会非常困惑,因为我想知道为什么要使用SqlParameters
表。没有其他代码的连接。考虑接受一个答案。考虑接受一个答案。