Skip to main content

Posts

Code to Get specified layer object in MSD axapta x++

This Job gets you the list of objects(Forms) which are developed in user layer. This can be achieved in many possible ways..This job will be time consuming as it uses tree node to find the objects. Also, if you click the object in the info displayed, the corresponding form gets opened. static void getLayers(Args _args) { treeNode treeNode; xInfo xInfo = new xInfo(); #AOT ; treeNode = xInfo.findNode(#FormsPath); treeNode = treeNode.AOTfirstChild(); while (treeNode) { if(treeNode.applObjectLayer() == utilEntryLevel::usr) { info(treeNode.TreeNodeName(),'', sysinfoaction_formrun::newFormname(treeNode.TreeNodeName(),'','')); } treeNode = treeNode.AOTnextSibling(); }

Get All the fields in a table through code in MSD axapta

Get All the fields in a table through code The idea behind writing this job is to make clear the concepts of sqlDictionay and how to get the fields from a table. Also a little introduction to file generation class(TextBuffer).This job create a CSV file by name fieldlist in C: drive static void fieldsInTable(Args _args) { str fieldList = ''; SqlDictionary sqlDictionary; TextBuffer buffer = new TextBuffer(); ; while select * from sqlDictionary where sqlDictionary.tabId==tablenum(salestable) { fieldList += sqlDictionary.sqlName; fieldlist += '\r'; } if (fieldList) fieldList = subStr(fieldList,1,strLen(fieldList)-1); buffer.setText(fieldlist); buffer.toFile("c:\\fieldslist.csv"); }

Set Mandatory fields in Table through code in MSD axapta

Set Mandatory fields in Table through code in ax DictTable dictTable; DictField dictField; tableId tableId; fieldId fieldId; str result; #DictField ; dicttable = new DictTable(tablenum(salestable)); for (fieldId = dictTable.fieldNext(0);fieldId;fieldId = dictTable.fieldNext(fieldId)) { dictField = dictTable.fieldObject(fieldId); if (!dictField.isSystem() && bitTest(dictField.flags(), #dbf_visible) && bitTest(dictField.flags(), #dbf_mandatory)) { result += dictField.name(); result +='\n'; } } info(result);

How to use like in range with wildcard character in MSD axapta

 How to use like in range with wildcard character in axapta Using wildcard "Like" //The "*" symbolises the like in the statement static void useWildCards(Args _args) { Query custQuery = new Query(); QueryRun queryRun; CustTable CustTable; ; custQuery.addDataSource(tablenum(CustTable)).addRange(fieldnum(CustTable, Name)).value('L*'); queryRun = new QueryRun(custQuery); while (queryRun.next()) { custTable = queryRun.get(tablenum(CustTable)); info(custTable.Name); } }

Query link and query build datasource example in MSD axapta

Query link and query build datasource example static void QueryLinks(Args _args) { Query query = new Query(queryStr(custtable));//Give your query name as in AOT... void getLinks(QueryBuildDatasource _qbds) { QueryBuildDataSource childDataSource; QueryBuildLink queryBuildLink; Counter links; int i; ; if (_qbds.enabled()) { setPrefix (tableId2Name(_qbds.table())); if(_qbds.level() > 1) { while (links < _qbds.linkCount()) { links++; queryBuildLink = _qbds.link(links); info(strFmt("%1.%2 --> %3.%4", tableId2Name(queryBuildLink.relatedTable()), fieldId2Name(queryBuildLink.relatedTable(), queryBuildLink.relatedField()), tableId2Name(queryBuildLink.table()), fieldId2Name(queryBuildLink.table(),queryBuildLink.field()))); } } for (i = 1; i <= _qbds.childDataSourceCount(); i++) { childDataSource = _qbds.childDataSourceNo(i); getLinks(childDataSource); } } } ; setPrefix(