Thursday, March 10, 2011

Spelling Checker in Axapta

This is very simple and quite interested code to check spelling in Axapta from Job

Try it !!!!!!!!!!!!

 static void Jit_Spelling_Checker(Args _args)
{
    SysSpellChecker sp = SysSpellChecker::newLanguageId('en-us');
    ;
       print(strfmt('%1',sp.checkSpelling("Microsoft")));
       print(strfmt('%1',sp.checkSpelling("Axapta")));
       print(strfmt('%1',sp.checkSpelling("Corner")));
       print(strfmt('%1',sp.checkSpelling("corz")));
       print(strfmt('%1',sp.checkSpelling("cornez")));
       pause;
}


In Next post we will test Spelling and print possible Suggetion .

Wednesday, March 9, 2011

Create Form Through Job

This is simple code to Create form through job


static void CSL_FormUsingCode(Args _args)
{
    Form                                       form;
    FormRun                                 formRun;
    Args                                        args;
    FormBuildDesign                     formBuildDesign;
    FormBuildControl                    formBuildControl;
    FormBuildTabControl              formBuildTabControl;
    FormBuildTabPageControl      formBuildTabPageControl;
    FormBuildGridControl            formBuildGridControl;
    FormBuildDatasource             formBuildDatasource;
    FormBuildStringControl          formString,formString1;
    ;

    form = new Form();
    formBuildDatasource         = form.addDataSource(tableStr(PurchTable));
    formBuildDesign                = form.addDesign('design');
    formBuildDesign.caption("JIT_testForm");
    formBuildTabControl         = formBuildDesign.addControl(FormControlType::Tab, 'Tab');
    formBuildTabPageControl  = formBuildTabControl.addControl(FormControlType::TabPage,'General');
    formBuildGridControl        = formBuildTabPageControl.addControl(FormControlType::Grid, 'Grid');
    formBuildTabPageControl.caption("General");
    formString                         = formBuildGridControl.addDataField(formBuildDatasource.id(), fieldNum(PurchTable,PurchId));
    formString1                       = formBuildGridControl.addDataField(formBuildDatasource.id(), fieldNum(PurchTable,PurchName));
    formString.label("PurchId");
     args = new Args();
    args.object(form);
    formRun = classFactory.formRunClass(args);
    formRun.init();
    formRun.run();
    formRun.wait();
}



Friday, March 4, 2011

Restore Ax Environment(Ldf,Mdf) to Unavailable Domain



Problem :
If u restore the Axapta Backup to unavailable Domain , Then U find following error


image 
Even the domain administrators do not gain access.
Context
User in Ax are link to the domain controller for which the system is installed. The users are ‘imported’ into Ax, resulting in the user actually be able to startup an Ax client, logging into Ax and performing actions for which the user has been granted access in Ax. 
This information, which user in which domain is allowed to perform which action is part of the Ax database. This includes any trusted domains, for example in case of a traditional perimeter network. 
But what if you restore an Ax database that was part of another domain? Even if you are the domain administrator, you will get the ‘You are not a recognized user of Microsoft Dynamics Ax. Contact your system administrator for help.’ message.  
Solution
The reason for this error is that the system only recognizes users from the old domain. This can be solved to updating the data directly using the database manager. In case of MS SQL server:
- Go to the Ax database. You can determine which database instance and database is used by checking the AOS configuration. 
- Find the dbo.USERINFO table
image 
- Open this table and find the record with ID value ‘Admin’. This user has in a normal scenario all rights, but may differ per installation. You can also use SQL to update the record, what ever makes you happy. 
- Update the following fields to reflect the current domain credentials. Bottom two lines can be ignored in this screenshot, the top line has the ID ‘Admin’ in this example:
image 
- SID – The Security Identifier of the account specified in the networkdomain and networkalias. See section ‘Get your SID’.
- NETWORKDOMAIN – you current login domain
- NETWORKALIAS – your current windows login name
- You might want to make sure the field ‘ENABLED’ has the value 1. Otherwise the user is disabled, and you will still not be able to login. 
- Save the record
- Open Ax
- Create your own users / import from the Domain. 






Get your SID
Create a file with the extension .VBS. Copy the following info:
--------------------
strComputer = "." 
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2") 
Set objAccount = objWMIService.Get("Win32_UserAccount.Name='<user>',Domain='<domain>'") 
Wscript.Echo objAccount.SID
---------------------
Replace <user> with your user name, and <domain> with the domain. This script can be run from any computer in the domain, it does not have to be the domain controller.  A popup will appear with your SID:
image