Thursday, September 4, 2008

Create Technical Document from AX

Creating detail technical document in projects is very time consuming. Isn’t it?

Particularly if there are many objects in the project it will take more time in creating it.

Here is the solution.This job will list the table fields properties like table field name,help text(Description),type, Size etc.

static void sgx_TehnicalDocument_Tables(Args _args)

{

COM document;

COM wordDocument;

COM wordRange;

COM app;

str tableContent;

SysDictTable dictTable;

SysDictField dictField;

Counter fieldCounter;

Counter arrayCounter;

str typeofTheField(DictField df, Types _types)

{

str typeName;

SysDictType dictType;

SysDictEnum dictEnum;

;

switch(_types)

{

case Types::UserType : dictType = new SysDictType(dictField.typeId());

return dictType.name();

case Types::Container : return 'container';



case Types::Date : return 'date';



case Types::Enum : dictEnum = new SysDictEnum(dictField.enumId());

if (dictEnum)

return dictEnum.name();

case Types::Integer :

return 'int';

case Types::Int64 :

return 'int64';

case Types::Real :

return 'real';

case Types::Record :

return 'record';

case Types::VarString :

case Types::RString :

case Types::String : return 'str';

case Types::BLOB : return 'blob';

case Types::DateTime : return 'datetime' ;

case Types::Guid : return 'guid' ;

default : return '';

}

}

;

app = new com("Word.Application");

app.visible(true);

document = app.Documents();

wordDocument = document.add();

wordDocument.activate();

wordRange = wordDocument.range(0,0);

dictTable = new SysDictTable(tablenum(CustTable)); // Mention your table here

for (fieldCounter = 1; fieldCounter <= dictTable.fieldCnt(); fieldCounter++)

{

dictField = new SysDictField(dictTable.id(), dictTable.fieldCnt2Id(fieldCounter));

if (!dictField.isSystem())

{

for (arrayCounter = 1; arrayCounter <= dictField.arraySize(); arrayCounter++)

{

dictField = new SysDictField(dictTable.id(), dictTable.fieldCnt2Id(fieldCounter), arrayCounter);

tableContent += dictField.name() + "\t" + dictField.help() + "\t" + typeofTheField(dictField, dictField.type()) + "\t" + int2str(dictField.stringLen()) + "\n";

}

}

}

wordRange.insertAfter(strfmt(tableContent));

wordRange.convertToTable();

}

Note: This has been developed as per my requirements. Beautifications and customizations can be done as per your requirements. I wrote simple job to do this. But it can be customized in such a way that you can right click the project- context menu- create technical document and will create the technical document for all the objects(Enums,EDT,Forms,classes etc) in the project.This development is in progress and will surely update this in the blog soon.

Now this is how the word document will be loaded with the data after running the job

No comments: