Hi guys, Today we see how how to get the selected records from grid in sys operation using x++ in D365FO.
Just check below code. Main code I have written in controller class.
Contract class:
[DataContractAttribute] public class TestrContract { List refRecId; [ DataMemberAttribute("refRecID"), AifCollectionTypeAttribute("_refRecID", Types::Int64), SysOperationControlVisibilityAttribute(false)// Hide control ] public List parmrefRecID(List _refRecID = refRecID) { refRecID = _refRecID; return refRecID; } } ---------------------------------------------------------------------------
Controller class: class TestController extends SrsReportRunController { public void new() { /*super(classStr(TestSysOperationService), methodStr(TestSysOperationService, process), SysOperationExecutionMode::Synchronous);*/ super(); this.parmClassName(classStr(TestSysOperationService)); this.parmMethodName(methodStr(TestSysOperationService, process)); this.parmDialogCaption("Dialog Title"); } public ClassDescription caption() { return "Task Description"; } public static void main(Args _args) { TestController controller = new TestSysOperationController();
//controller.captionIsSet = false; // controller.parmDialogCaption(isExcelUp ? "ExcelUpload" :"Manual"); controller.initFromCaller(); controller.refreshCallerRecord(); controller.startOperation(); } private void initFromCaller() { TestCustomer testCustomerLoc; FormDataSource testCustomer_DS; TestrContract contract; List myList; #define.dataContractKey('_contract') contract = this.getDataContractObject(#dataContractKey) contract.parmCallerTableId(this.parmCallerRecord().TableId); if(this.parmargs().dataset() == tableNum(TestCustomer)) { testCustomer_DS = FormDataUtil::getFormDataSource(this.parmCallerRecord()); myList = new List(Types::Int64); for (testCustomerLoc = getFirstSelection(testCustomer_DS); testCustomerLoc; testCustomerLoc = testCustomer_DS.getNext()) { myList.addStart(testCustomerLoc.RecId); } contract.parmrefRecID(myList); } } --------------------------------------------------------------------------------------
Service Class : public class TestSysOperationServiceClass extends SysOperationServiceBase { public void process(TestContractClass _contract) { info("Running"); List list = _contract.parmVendorList(); ListEnumerator enumerator = list.getEnumerator(); while(enumerator.moveNext()) { // your code. Info(strFmt('%1- recid', enumerator.current()); } } }
If u need for report please check my old post.
Keep Daxing!!
No comments:
Post a Comment