Saturday, January 11, 2014

Simple way of using Query and Query Run in X++

Static void QueryAndQueryRun(Args _args)
     Query query;
     Query queryrun;
     PurchTable purchtable;

     query = new Query();

     /*Used to display the sql query as string eg Select * from purchtable where purchtable.PurchId == "PurchId00001"*/
     queryrun = new QueryRun(query);
     /*query run has next() used to iterate through the query even though in this example we return only one matching record from purchtable */
          //query run has get() used return table buffer of the query. 
          purchtable = queryrun.get(tablenum(PurchTable));
          //throws info message of purchid. 

No comments:

Post a Comment