AIF: The class method for the specified action %1 could not be found

April 14, 2010 at 18:13
filed under AIF, Dynamics AX
Tagged , ,

When you get this error:

The class method for the specified action %1 could not be found

It probably means you have regenerated you classes using the AIF document wizard, or that you have imported the AIF classes without id’s.

You can use this job to fix the class id’s in the AIFAction table:

static void KlForFixAIFActions(Args _args)
{
    AIFAction   aIFAction;
    ClassId     classId;

    // inner method:
    // spit string at delimeter, keep left substring
    str lSplit( str _s, str _delimeter )
    {
        str s = "";
        int pos;
        int len = strlen( _s );

        pos = strfind( _s, _delimeter, 0, len );
        s = strdel( _s,pos,len-pos+1);

        return s;
    }
    ;

    // fix all actions
    while select aIFAction
    {
        // get 'real' classid
        classId = classname2id(lSplit(aIFAction.ActionId, '.'));

        // check if classid and classname match
        if(aIFAction.ClassId != classId)
        {
            if(classId == 0)
            {
                // class does not exist
                warning(strfmt("Class %1 does not exist", lSplit(aIFAction.ActionId, '.')));
            }
            else
            {
                // doesn't match
                // update classid
                ttsbegin;
                aIFAction.selectForUpdate(true);
                aIFAction.ClassId = classId;
                aIFAction.update();

                info(strfmt('Action %1 updated', aIFAction.ActionId));
                ttscommit;
            }
        }
    }

    info('done');
}

2 comments

RSS / trackback

  1. Cheryl

    Thanks for much for this code!

  2. Vimal

    Superb it resolved My issue

respond