D365F&O - X++ - Try and Catch block in x++ code

public class SalesOrderRefund
{
    public void process()
    {
        try
        {
            // your logic
        }
        catch(Exception::Error)
        {
            Microsoft.Dynamics.Ax.Xpp.ErrorException ex =
                        new Microsoft.Dynamics.Ax.Xpp.ErrorException();
            throw error(ex.Message);
        }
    }
}

Comments

Popular posts from this blog

D365F&O - X++ - Best Practice Warning BP Rule: [BPErrorUnknownLabel]: Path:

D365F&O - X++ - How to Enable/Disable button on form based on a condition in D365F&O using Event handlers.

D365FO - X++ - Generate CAR (Customized Analysis Report) report of custom model