Posts

Showing posts from 2015

Run AX client with out load balance AOS

Open command promt as admin Navigate to client bin folder cd C:\Program Files (x86)\Microsoft Dynamics AX\60\Client\bin AX32.exe -loadbalance=0 -aos2=servername:2712 to login to the intended AOS add loadbalance, value, 0 parameter to .axc client configuration

X++ job to get user assigned security roles

static void Job6(Args _args) {     SecurityInfoTable axpUserSecurityTmp;     SecurityUserRole securityUserRole;     SecurityRole securityRole;     SecurityTask securityTask;     UserInfo     userInfo;     SecurityRoleAllTasksView securityRoleAllTasksView;     OMUserRoleOrganization roleOrganization;     OMInternalOrganization internalOrganization;     while select securityUserRole        outer join securityRole                 where securityRole.RecId == securityUserRole.SecurityRole        join userInfo             where userInfo.id == securityUserRole.User             && userInfo.enable == NoYes::Yes        outer join securityRoleAllTasksView                 where securityRoleAllTasksView.SecurityRole == securityUserRole.SecurityRole                     outer join securityTask                     where securityTask.RecId == securityRoleAllTasksView.SecurityTask                         outer join roleOrganization              

X++ Send Email

SysEmailTable::sendMail(sysEmailId,SysEmailTable::find(sysEmailId).DefaultLanguage , outEMailAddr,     null,     filename,     '',     true,     curuserid(),     true);

X++ Get Admin access

static void AdminOn(Args _args) {     SecurityUtil::sysAdminMode(true);     info("AdminOn"); } static void AdminOff(Args _args) {     SecurityUtil::flushAll();     SecurityUtil::sysAdminMode(false);     info("AdminOff"); }

Get dimension values for a particular financial dimension

Financial Dimension can be custom(new ones) or existing(customer,Item,Department) DimensionAttribute table has all the Financial dimensions,this is the main table to drilldown to get the dimension values of each dimenion. Dimension values for above dimensions sit in different tables or views like OMoperatingunitview, OMDepartmentView, DimattributeOMcostcenter etc. dimensionattributevalue table has mapping for above two(dimension and dimensionvalue) To get dimension values for a particular dimension, below code can be used. Dimension attribute table holds the tableId which has the dimensionvalue. while select BackingEntityTableId, BackingEntityValueFieldId, Type from dimensionAttribute where dimensionAttribute.type == j     {         dictTable = new dictTable(dimensionAttribute.BackingEntityTableId);         common = dictTable.makeRecord();         id = dimensionAttribute.BackingEntityValueFieldId;         while select * from common join EntityInstance, DimensionAttr

X++ Pass SSRS query ranges

This method works fine on the job and also once the batch job or on the server public void getSSRSReport(Filename  filename,FilePath        filepath ) {     Query reportRunQuery;     str querykey;    // filename = "Report.pdf";     //filename = filepath + filename;     this.parmReportName(ssrsReportStr(Report,Autodesign));     querykey =    this.getFirstQueryContractKey();     this.parmReportContract().parmQueryContracts().remove(querykey);     reportRunQuery = new Query(queryStr(query name));     SrsReportHelper::addParameterValueRangeToQuery(reportRunQuery, tableNum(UserInfo),fieldNum(UserInfo, id),"abc.da");     this.parmReportContract().parmQueryContracts().insert(querykey, reportRunQuery);     this.parmReportContract().parmPrintSettings().printMediumType(SRSPrintMediumType::File);     this.parmReportContract().parmPrintSettings().overwriteFile(true);     this.parmReportContract().parmPrintSettings().fileFormat(SRSReportFileFormat::PDF);     this.parmReportCont

Hold all batch jobs

  To hold all batch jobs. Create a new Job  Add below code to job and execute. All the batch jobs with status waiting will be changed to hold.     BatchJob job;         ttsBegin;     while select forUpdate job where job.Status == BatchStatus::Waiting     {         job.Status = BatchStatus::Hold;         job.update();             }     ttsCommit;

Form as field look up in another form

A new field is added and that should show a already created form as its lookup. Create a new form with datasources and design. In design properties give window type-content page, style- lookup public void lookup() {    SysTableLookup          sysTableLookup ;     Query                   query           = new Query();     QueryBuildDataSource    queryBuildDataSource;     QueryBuildRange         queryBuildRange;     DimensionValue  value;     Args args;     FormRun formRun;     ;     args = new Args();     args.name("HcmWorkerEligibleLookup");     args.record(PurchReqTable);     args.parmEnum(NoYes::Yes); //     args.caller(this); //     formRun = classFactory.formRunClass(args);     formRun.init();     formRun.run();     formRun.detach();     this.performFormLookup(formRun); } In the created form init method give public void init() {     super(); this.selectmode(formname_field from datasource to be shown in the lookup eg: this.selectMode

Forms to store last filter values

Use SysEPCustomFilter class to save the last filter values on forms or listpages Use projprojectslistpageInteraction class to see more about the functionality

SQL: view database restore history

SELECT [rs].[destination_database_name], [rs].[restore_date], [bs].[backup_start_date], [bs].[backup_finish_date], [bs].[database_name] as [source_database_name], [bmf].[physical_device_name] as [backup_file_used_for_restore] FROM msdb..restorehistory rs INNER JOIN msdb..backupset bs ON [rs].[backup_set_id] = [bs].[backup_set_id] INNER JOIN msdb..backupmediafamily bmf ON [bs].[media_set_id] = [bmf].[media_set_id] ORDER BY [rs].[restore_date] DESC