Langsung ke konten utama

Postingan

Create an Excel File using X++

Create an Excel File using X++ Creating an excel file is essential mostly in data import or export. Microsoft Dynamics AX has a feature to import and export through excel template. But in some cases, you need to create an excel to integrate with other application. Below is an example of creating an excel file in X++ using an existing table in AX. static void ExportToExcel(Args _args) { #AviFiles SysOperationProgress progress = new SysOperationProgress(); SysExcelApplication sysExcelApplication; SysExcelWorkbooks sysExcelWorkBooks; // Filename to which you will be writing your data FileName fileName = "C:\\Windows\\Temp\\ExportToExcel.xlsx"; SysExcelWorkbook sysExcelWorkBook; SysExcelWorkSheets sysExcelWorkSheets; SysExcelWorkSheet sysExcelWorkSheet; SysExcelWorkSheet sysExcelWorksheetBackOrder; SysExcelWorksheet sysExcelWorkSheetToBeDeleted; SysExcelStyles ...

How to Round Up and Round Down Numbers In AX

To round number in AX, we can use 2 method. If we wanna round up, we can use  RoundUp(real value, real unit)  function and we can use  RoundDown(real value, real unit)  function if we wanna round down numbers. For example, we can see the source code of a job below : static void Rounding(Args _args) {     real    temp, roundingUp, roundingDown;     ;     temp = 3000 / 7;     roundingUp = roundUp(temp, 1);     roundingDown = roundDown(temp, 1);     info(strFmt("Origin : %1 RoundingUp : %2 RoundingDown : %3", temp, RoundingUp, roundingDown)); } The result is like a picture below :

Delete indexeddb data by index

var indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB || window.msIndexedDB; var IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction || { READ_WRITE: "readwrite" };; var db; var transaction, objectStore; var request = indexedDB.open("IndexedDBname", 1);         request.onsuccess = function (evt) {        db = request.result;  var deleteindex = db.transaction(["indexdbtable"], "readwrite") .objectStore("indexdbtable")                 .delete(1); // example if you want to delete index no 1 deleteindex.onsuccess = function(event) { console.log("index 1 deleted" + "indexdbtable");  // log };  };

Function to delete Indexeddb Object(table)

var indexedDB = window.indexedDB || window.webkitIndexedDB || window.mozIndexedDB || window.msIndexedDB; var IDBTransaction = window.IDBTransaction || window.webkitIDBTransaction || { READ_WRITE: "readwrite" };; var db; var transaction, objectStore; // "IndexDB" is your indexed db name (database) var request = indexedDB.open("IndexDB", 1);         request.onsuccess = function (evt) {         db = request.result; //"indexobject" is your indexdb object (table) transaction = db.transaction("indexobject", "readwrite"); objectStore = transaction.objectStore("indexobject");   // clear all the data out of the object store var objectStoreRequest = objectStore.clear(); objectStoreRequest.onsuccess = function(event) {     // report the success of our clear operation console.log('clear '+"indexobject"); }; };

IndexedDB Fuzzy Search

This is how to create  key range between the search term and the search term with a 'z' letter at the final. db . transaction ([ 'table' ], 'readonly' ) . objectStore ( 'table' ) . openCursor ( IDBKeyRange . bound ( searchTerm , searchTerm + '\uffff' ), // The important part, thank Velmont to point out 'prev' ) . onsuccess = function ( e ) { e || ( e = event ); var cursor = e . target . result ; if ( cursor ) { // console.log(cursor.value.column1 + ' = ' + cursor.value.column2); cursor . continue (); } }; If you need to order the result, so I defined a array before the transaction, then we call it when we loaded all data, like this: var result = []; db . transaction ([ 'table' ], 'readonly' ) . objectStore ( 'table' ) . openCursor ( IDBKeyRange . bound ( searchTerm , searchTerm + '\uffff' ), // The important ...

Use HTML5 IndexedDB cursors to update existing records

The  HTML5   IndexedDB  is still in the working draft stage and not fully implemented in major Internet browsers yet. Nevertheless, I tried to use its asynchronous API to develop a  Google Maps  application. It took me a little while to figure out how to update an existing record in the IndexedDB  database store. This can be done by opening a read-write cursor to the record to be updated. Then call the cursor  update  method to replace it with the new record. An example Javascript code snippet is shown below. try { var objDb; //the database to update var store = 'myStore' ; //the database store to update var key = 88; //the key of the existing record to update var newRec = 'hello world' ; //the new record var objStore = null ; var objTrans = null ; var objCursor = null ; var objKeyRange = null ;   //...etc...open the database....etc... //open a read-write transaction objTrans = objDb.transaction(store,...

How to enable mixed authentication in sql server

On the SQL Server start  SQL Server Management Studio   Enter the  Server name  and select  Windows authentication . Make sure you are logged in with administrator credentials.   Right click on the server name and select  properties   Go to  Security  and select  SQL Server and Windows Authentication Mode .   Right click on the server name and select  Restart  to restart the SQL services.