[英]How to achieve SQL “ON” functionality in Dynamics AX
I have the following query 我有以下查询
select x from ProjTable
join GeneralAccEntry
on (Projtable.ProjId= substr(GeneralAccEntry.fieldy), 25,7)
I created a form with ProjTable
as main datasource. 我创建了一个以
ProjTable
作为主要数据源的表单。 Now I want to add a calculated display field which shows the sum of fieldY
from the related GeneralAccEntry
table. 现在,我想添加一个计算的显示字段,该显示字段显示相关
GeneralAccEntry
表中fieldY
的总和。 I'm having difficulties retrieving the sum per projId
because the method doesn't take projId
as a parameter. 我在检索每个
projId
的总和时遇到了困难,因为该方法未将projId
作为参数。
What's the correct way to create this display method? 创建此显示方法的正确方法是什么?
Just try with "WHERE" instead of "ON". 只需尝试使用“ WHERE”而不是“ ON”即可。
select x
from ProjTable
join GeneralAccEntry
WHERE Projtable.ProjId = substr(GeneralAccEntry.fieldy, 25,7)
Be careful with comparing using a function, it may give you an error. 使用功能进行比较时要小心,这可能会给您带来错误。 In case it does try to assign the result of the substr to a str variable with a defined length (like str 20 varName).
如果确实尝试将substr的结果分配给具有定义长度的str变量(如str 20 varName)。
Not sure if I understand your question correctly. 不知道我是否正确理解您的问题。 But would the following resolve your problem:
但是以下方法可以解决您的问题:
Add method to your table ProjTable:
public display real sumOfGeneralAccEntry()
{
GeneralAccEntry generalAccEntry;
str filter = '*' + this.ProjId + '*';
select sum(fieldY)
from generalAccEntry
where generalAccEntry.fieldY like filter;
return generalAccEntry.fieldY;
}
Add the display to a field group
Add the fieldgroup into your form
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.