Created
June 27, 2025 14:33
-
-
Save d47447/8f14cadb0f3532840114b9d2911ca5f4 to your computer and use it in GitHub Desktop.
Custom web service in D365FO - Part-II
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public TheAxaptaResponseContract processMsg(TheAxaptaRequestContract _request) | |
| { | |
| TheAxaptaResponseContract response = new TheAxaptaResponseContract(); | |
| try | |
| { | |
| str storeId = _request.parmStoreNumber(); | |
| str trackingNumber = _request.parmTrackingNumber1(); | |
| // Example: Validate store ID | |
| if (storeId == "") | |
| { | |
| response.parmSuccess(false); | |
| response.parmMessage("Store ID is required."); | |
| return response; | |
| } | |
| // Example: Fetch sales order based on tracking number | |
| SalesTable salesTable; | |
| select firstOnly SalesId from salesTable | |
| where salesTable.TrackingNumber == trackingNumber; | |
| if (salesTable) | |
| { | |
| response.parmSuccess(true); | |
| response.parmMessage("Sales order found."); | |
| response.parmDebugMessage(strFmt("SalesId: %1", salesTable.SalesId)); | |
| } | |
| else | |
| { | |
| response.parmSuccess(false); | |
| response.parmMessage("No sales order found for the given tracking number."); | |
| } | |
| } | |
| catch (Exception::CLRError) | |
| { | |
| response.parmSuccess(false); | |
| response.parmMessage("CLR error occurred."); | |
| response.parmDebugMessage(AifUtil::getClrErrorMessage()); | |
| } | |
| catch (Exception::Error) | |
| { | |
| response.parmSuccess(false); | |
| response.parmMessage("An unexpected error occurred."); | |
| response.parmDebugMessage(AifUtil::getErrorMessage()); | |
| } | |
| return response; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment