Skip to main content

Posts

Showing posts with the label records

AXAPTA refreshing records

repairjournal_ds.research(); repairjournal_ds.refresh(); If you want to stay at current record: repairjournal_ds.research(true); repairjournal_ds.refresh();

Pass the Data Source records to Class or pass the multiple records to class

http://axhelper.blogspot.com/ 1. Add a action MenuItem in a form as a MenuItemButton. 2.Take a clicked method() void clicked() { MenuFunction mf;Pass the Data Source records to Class or pass the multiple records to class args args = new Args(); ; args.record(Table1); mf = new menufunction(identifierstr(classParmData), MenuItemType::Action); mf.run(args); } 3.Take a class class ClassParmData { Table1 tb1;// table variable declaration } —- public static void main(Args args) { ClassParmData _ClassParmData; Table1 _table1; FormDataSource fds; ; if(args.record().TableId == tablenum(Table1)) _table1 = args.record(); // assigning the selected record fds = _table1.dataSource();// getting the datasource _ClassParmData = new ClassParmData(fds); //passing the datasource records to New() method /*_table1 = fds.getFirst(); // can loop all the record here also while(_table1)//fds.getNext()) { info(strfmt(_table1.Field1)); _table1 = fds.getNext(); }*/ } —– void new(FormDataSource fdst) // receving th...

Comparing records

Sometimes you need to know what’s the difference between records. I made a simple function to do just that.It takes two records and returns a container with the field IDs and the values from both records. For simplicity I used a flattened container instead of more complicated data structures. Feel free to replace it with nested containers or some kind of collection. I added this to the class Global for easy access. public static container compareRecords ( Common _record1 , Common _record2 ) { SysDictTable dictTable = new SysDictTable ( _record1. TableId ) ; SysDictField dictField; FieldId fieldId , extFieldId; container ret; int i , j; ; if ( _record1. TableId != _record2. TableId ) return conNull ( ) ; for ( i = 1 ; i <= dictTable. fieldCnt ( ) ; ++ i ) { fieldId = dictTable. fieldCnt2Id ( i ) ; dictField = new SysDictField ( _record1. tableId , fieldId ) ; i...

X++ Code Snippet: Copying records

static void CopyFields(Common _from, Common _to) {      DictTable           t;     DictField           f;     int                  i;      fieldId             id;     FieldName           fieldname;      ;     t = new DictTable(_to.TableId);     if (t)     {         for (i= 1 ; i<=t.fieldCnt(); i++)         {             id = t.fieldCnt2Id(i);             f  = new D...

Count total number of records in axapta x++

Sometimes, we need to know the number of records in a axapta x++ query... so it's possible! Just we use the SysQuery::countTotal(queryRun) function to count the number of query records. However, this function count only the number of records of the first datasource... if we need to count the number of records of a query with more than one datasources... we need to use the SysQuery::countLoops(queryRun) instead of SysQuery::countTotal(queryRun) .