Skip to main content

Posts

Showing posts with the label counter

How to Call query in MSD Axapta by code

To Call query in Axapta by code you can try below code. You need to create query in aot query node then pass query using querystr method in queryrun object. QueryRun queryRun; int cnt; ; queryRun = new QueryRun(queryStr(Query1)); if (queryRun.prompt()) { while (queryRun.next()) { cnt++; }

show data source information using MSD axapta

show data source information using axapta FormDatasource formDatasource; FormGroupControl formGroupControl; FormStaticTextControl formStaticTextControl; Counter counter; Counter noOfDatasources; ; noOfDatasources = this.form().dataSourceCount(); if (noOfDatasources) { formGroupControl = this.form().design().addControl(FormControlType::Group, "formGroupControl"); formGroupControl.caption("Tables used by form"); formGroupControl.frameType(3); } for (counter=1; counter <= noOfDatasources; counter++) { formStaticTextControl = formGroupControl.addControl(FormControlType::StaticText, "formStaticTextControl" + int2str(counter)); formStaticTextControl.text(tableid2name(this.form().dataSource(counter).table())); }

exception handling in X++ MSDAX

Try-catch statements are used for exception handling in X++. A try-catch statement consists of two or more separate blocks of code, a try block which attempts some operation, and one or more catch blocks where exceptions thrown within the try block are caught. Exceptions may either be thrown by the kernel or by using the command throw from code within the try block. The catch part takes action on exceptions. You may have multiple catch blocks, each designed to catch a particular type of exception. Action will only be taken on types of exceptions explicitly referenced in your code. The try-catch example shown will take action on the exception type's error and warning. static void Intro_TryCatch(Args _args) { Counter counter; try { while (counter < 10) { counter++; if (counter MOD 7 == 0) throw error("Counter MOD 7 is zero"); if (counter MOD 3 == 0) throw warning("Counter MOD 3 is zero"); } } catch (Exception::Erro...