Archive

Archive for April, 2009

Disable Driver Signing in Windows Vista / Windows 7

April 30th, 2009 4 comments

Today I wanted to install USB drivers from garmin on my box running Windows 7. Windows started complaining about the driver not being signed and thus I could not proceed with the installation of the garmin software.

The solution here is to disable the driver signing. You can do this in several ways.

  • First is to run some dos commands to disable it but I am not going to describe this here for the simple fact that this method does not work anymore after some of the updates are already present.
  • Second is to disable Driver Signing Enforcement at bootup. You can call up the advanced boot menu by Pressing F8 and then there is an option to disable driver signing enforcement. This does work and solved the problem for me because the driver neatly installed.
  • Third manner of doing this is the automated version of the second way : Ready Driver. Ready driver is a tool that will run at bootup and will automatically do the steps for you without you needing to do them. The thing here is that by doing it this way, you always have it disabled.

advancedbootoptions

I used the second method because I just wanted to disable it for this bootup.

Dynamics Ax Get and Remove text from the Infolog

April 29th, 2009 2 comments

Sometimes you want a process to log infolog data into a text field instead of sending it to the infolog. For example you are posting 6 custom made journalTables and if something goes wrong you want the infologdata to be stored in a Log field on the table and you want to continue with the processing of the other journalTables.

Then you will have a catch statement where you will need to get the infolog data and store it into the field but there are some difficulties :

  • First you want only the data generated by your process and not the data that might have already been in the infolog.
  • Second you want to clear the errors from you code from the infolog without clearing all the rest of the infolog data.

The key is to work with the infolog.line() method to remember when to start keeping track of the lines in the infolog.

We can demonstrate this with the following job :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
static void LIB_KeSae_TestInfologRemoval(Args _args)
{
    int line;
    str omittedText;
    ;
 
    error("error1");
    error("error2");
 
    // Now we have 2 records in the infolog
    // From now on we want the following entries in the infolog to be stored
    // somewhere and omitted from the infolog window
 
    // Remember the number of entries before the custom code (in this case line = 2)
    line = infolog.line();
 
            //Customer code
            error("error3");
            error("error4");
            error("error5");
 
    // Here we want to retrieve statement 3, 4 and 5 en clear those from the infolog
    omittedText = global::LIBGetTextFromInfoLog(line + 1, true);
 
    // Some infolog entries after our code
    error("error6");
    error("error7");
}

The following code is the code from the GetTextFromInfolog method :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
public static str LIBGetTextFromInfoLog(int _startLine = 1, boolean _clearInfo = true)
{
    int currentLine;
    str retValue;
    ;
 
    /*
        Do not use infolog.infologData to get the infolog data because that creates a copy and clears the actual infolog.
        Then the infolog.line() method will return 0 afterwards and you cannot clear the selected lines anymore
    */
 
    for(currentLine = _startLine; currentLine < = infolog.line(); currentLine++)
    {
        retValue += 'n' + infolog.text(currentLine);
    }
 
    // _startLine -1 because the infolog method will add 1
    if(_clearInfo)
        infolog.clear(_startLine -1);
 
    return retValue;
}

The infolog.clear() method will now take the startline into account and only clear the infolog entries from our code and leave the other entries intact as shown in the result of this job :

Result of the infolog after removing entries

Result of the infolog after removing entries

Dynamics Ax Disable / Enable all datasource fields

April 28th, 2009 No comments

Sometimes you want to disable all fields on a form’s datasource and enable some of them afterwards. Put the following piece of code in the Global class and you can call it from wherever you like.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
public static void LIBSetAllTableFields(FormDataSource _formDataSource,Boolean _value)
{
    DictTable       dictTable = new DictTable(_formDataSource.table());
    int             i;
    int             fieldNumber;
    ;
    for(i = 1;i < = dictTable.fieldCnt();i++)
    {
        fieldNumber = dictTable.fieldCnt2Id(i);
        if(_formDataSource.object(fieldNumber))
        {
            _formDataSource.object(fieldNumber).allowEdit(_value);
        }
    }
}

First speak… then think

April 23rd, 2009 No comments

First speak, then think… of was het nu omgekeerd…

Vandaag had ik terug avondschool elektriciteit. Het was al enkele weken geleden (leraar ziek enzo…) maar vandaag kwam ik daar aan en ik zag al dat er geen al te grote opkomst was. Ik kwam in ieder geval enthousiast genoeg binnen en met genoeg volume gooi ik de vraag de groep in : “En waar zit onze vriend !?” (Erwin de Vriendt is de naam van leerkracht)

Meteen antwoorden enkele van de klasgenoten in koor : “Die komt niet meer, we hebben nu officieel de 4e leerkracht van het jaar !” Waarop ik meteen zonder al te veel te denken response begin te geven : “Alle da werd tijd want we zagen niets meer van leerstof ! Tis te hopen dat die nieuwe het wat beter doet en zo of ik zal het hem wel eens goed zeggen hoe het moet !”

Net op dat moment begint mijn rechter hemisfeer in mn bovenkamer de prikkels binnen te krijgen die afkomstig waren van mijn ogen… en daarin stond geëncrypteerd dat er in de linkerhoek van het lokaal al een nieuwe persoon zat…. de nieuwe leerkracht !

Dus na mijn welbespraakte intro begonnen we dan toch maar aan de les en kreeg ik met plezier te horen dat die nieuwe leerkracht ervan overtuigd was dat we nog enkele dingen misten en vooral het feit dat we nog niet op de Pc grondplannen en schema’s getekend hadden. Dus vandaag was alvast cool omdat we nu eindelijke met Caddy++ gaan werken.

Ook getest op Mensen

April 22nd, 2009 No comments

Toch nog een programma gevonden die de moeite waard is om kostbare tijd die we in te kleine hoeveelheden hebben toch aan te spenderen : Ook getest op mensen. En wat heeft ons dat bijgebracht….

  • De wii-fit is echt wel goed voor het lichaam
  • De hoorschade die we dagelijks oplopen door muziek / cinema is toch verbluffend : Oplossing voor het probleem is oordopjes in de oren proppen !??! Zou het niet helpen om de volumes naar beden te halen? Neen , zet maar effe harder, ik heb toch oortjes op zeggen de meeste
  • Toch minder hersencellen verloren dan een gemiddeld VTM uurtje gevuld met “the sound of music” brol.

Voor de rest was het Marcel van thilt die toch moeite vertoont om bij het stellen van een vraag ook een antwoord af te wachten…

Generic SysTableLookup Method

April 22nd, 2009 1 comment

It is often needed to write a custom lookup method and the SysTableLookup class can be useful to create lookups from code. However the following method uses the SysTableLookup in the background but can be called easier.

When using the SysTableLookup class, for most of the simple lookups (1 datasource table) it is alway the same. You need the following :

TableId, LookupControl, LookupFields, ReturnFields, SortFields and sometimes the use of a tmpTable.

Now following method is a generic method to user the SysTableLookup class :

public static void doLookup(TableId             _tableId,
                            Container           _lookupFields,
                            Container           _sortFields,
                            FormStringControl   _control,
                            FieldId             _returnItemFieldNum,
                            Map                 _queryRanges    = null,
                            Boolean             _useTmpTable = false,
                            Common              _tmpBuffer = null
                            )
{
    SysTableLookup          sysTableLookup  = SysTableLookup::newParameters(_tableId, _control);
    Query                   query           = new Query();
    QueryBuildDataSource    qbds;
    int                     i;
    fieldId                 lookupFieldId;
    ;
 
    for(i=1;i &lt;= conlen(_lookupFields);i++)
    {
        lookupFieldId = conPeek(_lookupFields, i);
 
        if(lookupFieldId == _returnItemFieldNum)
            sysTableLookup.addLookupfield(lookupFieldId, true);
        else
            sysTableLookup.addLookupfield(lookupFieldId);
    }
 
    qbds = query.addDataSource(_tableId);
 
    for(i=1;i &lt;= conlen(_sortFields);i++)
    {
        qbds.addSortField(conPeek(_sortFields, i));
    }
 
 
    if(_queryRanges)
    {
        rangeEnumerator = _queryRanges.getEnumerator();
 
        while (rangeEnumerator.moveNext())
        {
            qbds.addRange(rangeEnumerator.currentKey()).value(any2Str(rangeEnumerator.currentValue()));
        }
    }
    if(_useTmpTable)
        sysTableLookup.parmTmpBuffer(_tmpBuffer);
 
    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();
}

Now when you want to create a lookup you can do it easier by doing the following :

public void lookup()
{
    Container   fieldNums       = [FieldNum(CustTable, AccountNum), FieldNum(CustTable, Name)];
    Container   sortFields      = [FieldNum(CustTable, AccountNum)];
    FieldId     returnFieldId   =  FieldNum(CustTable, AccountNum);
    Map         queryRanges     = new Map(Types::Integer, Types::String);
    ;
    queryRanges.insert(FieldNum(CustTable, AccountNum), '4000');
    LIBSysTableLookup::doLookup(TableNum(CustTable), fieldNums, sortFields, this, returnFieldId, queryRanges);
}

So the only thing you need to do is specify the fields, returnfields and sortfields…

Ans let’s look at the following example : We need a lookup with a temporary table. Then we can do it like this :

Container   fieldNums       = [FieldNum(TmpIdRef, Name), FieldNum(TmpIdRef, HelpTxt)];
    Container   sortFields      = [FieldNum(TmpIdRef, Name)];
    FieldId     returnFieldId   = ConPeek(fieldNums, 1);
    TmpIdRef    tmpTable;
    ;
    tmpTable = LIBDifferenceAction::BuildActionClassList();
 
    LIBSysTableLookup::doLookup(TableNum(TmpIdRef), fieldNums, sortFields, this, returnFieldId, true, tmpTable);

EventHandlers In Ax 2009

April 22nd, 2009 1 comment

It is possible to attach event listeners to objects in X++.
The next code sample shows the usage of the SysEventBroker and SysEventInfo classes to handle events :

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
static void SysEventTest(Args _args)
{
SysEventBroker broker = SysEventBroker::construct();
SysEventInfo info1 = new SysEventInfo("Info-1"); // catch all;
SysEventInfo info2 = new SysEventInfo("Info-2"); // catch specific class
SysEventInfo info3 = new SysEventInfo("Info-3"); // catch specific type
;
// Setup
broker.addListener(info1, classNum(Object));
broker.addListener(info2, classNum(Runbase));
broker.addListener(info3, classNum(Object), "Fire 2"); // catch Fire 2
broker.addListener(info3, classNum(Object), "Fire 4"); // and Fire 4
 
broker.fireEvent(classNum(CustAutoCreate), "Fire 1", "This is my life");
broker.removeListener(info2, classNum(Runbase));
broker.fireEvent(classNum(CustAutoCreate), "Fire 2", "this is my time");
broker.fireEvent(classNum(CustAutoCreate), "Fire 3", "just show me the light");
broker.removeListener(info1);
broker.fireEvent(classNum(CustAutoCreate), "Fire 4", "and I go there");
}

W@xWe@zel @ WordPress

April 21st, 2009 2 comments

Ok … het is zover … het niet ophoudend enthousiasme van de Kevin heeft me dan toch overtuigd om eens de mogelijkheden van WordPress te bekijken !

Tot dusver bevalt het gebruiksgemak me al, nu nog de boel opfleuren en vullen met zever.

Greets,
Waxie