I’m trying to create a method in the SalesLine table which will return a sum total of the amount of confirmations associated with a SalesLine. However I’m running into a bit of bother with the return type - I assumed this would be an integer?
This is the method as it stands:
display int allConfirmations(SalesLine t)
{
CustConfirmTrans custConfirmTrans;
select sum(ConfirmId) from custConfirmTrans
where custConfirmTrans.InventTransId == t.InventTransId && custConfirmTrans.SalesId == t.SalesId;
return CustConfirmTrans.ConfirmId;
}
Is there something I’m missing here? It did occur to me I might be getting the return statement wrong also.
I don’t know your AX version but it seems that you want to sum a string (confirmId). A display method does not take any parameters. you should use salesline instead of custConfirmTrans to sum amount values
try something like the following:
display AmountCur yourSum()
…
select sum(lineAmount) from SalesLine where blablabla
return salesLine.LineAmount;
Hope it helps, please verify solution if it solves your problem
This is actually a modification of an already working display method which takes SalesLine as a parameter - I believe it was so it would display the correct value for each line on a form?
I use AX 2012 R2, apologies for not stating it in the original post, I thought tagging the post would suffice
I understand what you mean about the string value - I didn’t realise Sum was trying to add all the contents together, I was actually looking for a method to count them? I have just tried changing Sum to count and it returns the same error however - is there a better field to be checking for counting them?
P.S. Your current solution would return the amount of lines on the sales order however, not the amount of confirmations associated with the line surely?