Making Maintain Charges mandatory at So Confirmation Level

Hi expert, i want to make maintain charges mandatory on Sales Order Confirmation level, i.e system check before posting so confirmation that maintain charges are inserted for that SO. if yes then system allow me to post so confirmation , and if not then system throw error,

plz guide.

You can have your logic to check if there are any charges applied on that sales order in check() method of \Classes\SalesConfirmJournalCreate

BTW, always tag your AX version. The above is for AX 2012.

thanks for your prompt reply, i just follow you instruction and create a new method with following code,

protected void CheckMarkupTrans(SalesId _salesId)
{
SalesTable sales;
MarkupTrans t;
MarkupTable m;
SalesLine l;
select * from sales
join l
where sales.SalesId==l.SalesId && sales.SalesId==_salesId
notExists join t
where t.TransTableId==l.TableId && t.TransRecId==l.RecId
join m where t.MarkupCode==t.MarkupCode && t.ModuleType==t.ModuleType;

if(l.ExFor==ExFor::For && t.MarkupCode=="")
{
throw error(“Please Update Codes For Sales”);
}
}

but it did not work .

You need to have your code in check method (override check method).

Your select statement will also not work. You need to check if there is a markUpTrans related to salesTable and salesLine. If there is no markupTrans throw the error.

thanks for your valuable suggestion. can you please give code hints,

If you override check method , i think you will be able to access the salesTable buffer (that is already declared in class declaration)

MarkUpTrans markUpTrans;

salesTable salesTableLocal;

select firstonly RecId from markupTrans

exists join salesTableLocal

where salesTableLocal.RecId == markUpTrans.TransRecId

&& salesTableLocal.tableId == markupTrans.TransTableId

&& salesTableLocal.salesId == salesTable.salesId; // salesTable variable is already available

if (!markupTrans.RecId)

{

/// error here

}

I have just typed the code here, so take care of the syntax/spelling/indentations. Use similar code for sale Line

thanks alot, but the code you provided not working at all.

i have a field at sales table header Exfor which have one value at a time, either ex, or For, i want make the condition for the For,thanks for your prompt reply

That is only a sample code. If you just copy and paste, it may not work. You have to modify it as per your requirement.

this is my code

boolean ret;
MarkUpTrans markUpTrans;
//boolean ret;
salesTable salesTableLocal;
// ret=super();
select firstonly RecId from salesTableLocal
join salesTable
where salesTableLocal.salesId == salesTable.salesId
notexists join salesTableLocal

where salesTableLocal.RecId == markUpTrans.TransRecId

&& salesTableLocal.tableId == markupTrans.TransTableId;

// && salesTableLocal.salesId == salesTable.salesId; // salesTable variable is already available

if (markupTrans.MarkupCode==’’ && salesTableLocal.ExFor==ExFor::For)

{

ret=checkFailed("Please update Charges Code ");
//ret=false;

}
//return ret;

ret = super();

return ret;
}

Why are you joining the same salestable multiple times. You are not selecting the markupTrans anywhere. Have you tried using the code i suggested?

This needs to be in the begging.

yes but that code was not working…

Can you show that code? Have you checked why it is not working?

MarkUpTrans markUpTrans;

salesTable salesTableLocal;
boolean ret = super();
select firstonly RecId from markupTrans

exists join salesTableLocal

where salesTableLocal.RecId == markUpTrans.TransRecId

&& salesTableLocal.tableId == markupTrans.TransTableId

&& salesTableLocal.salesId == salesTable.salesId; // salesTable variable is already available

if (!markupTrans.RecId && salesTable.ExFor==ExFor::For)

{

error("Check Charges Code ");
}
//return ret;

return ret;
}

You are not setting any value to ret.

ret=checkFailed("Please update Charges Code ");

This condition can be moved to top. (like below code). Also generate incremental IL. If you see any issue, try debugging.

if (salesTable.ExFor==ExFor::For)

{

select firstonly RecId from markupTrans

exists join salesTableLocal

where salesTableLocal.RecId == markUpTrans.TransRecId

&& salesTableLocal.tableId == markupTrans.TransTableId

&& salesTableLocal.salesId == salesTable.salesId; // salesTable variable is already available

if (!markupTrans.RecId )

{

ret=checkFailed("Please update Charges Code ");
}

}

not working, can i share my screen with you!

thanks it working now.after genterating CiL

one problem is that its generating Error for all, means its stoping All Sales order confirmation either For or Ex, i want to apply just for For, not on others…plz

and also if i give marktup Trans , it also give me the error, update charges code,

where is the problem. now!