Tuesday, August 19, 2014

Create and implement sequence number

Scenario:
New Reservation code, ST

Step 1:
Create new sequence number into number sequence setting












Step 2:
Insert code into table layer method.


Step 3:
Implement methods into form base datasource methods.





Friday, July 25, 2014

Custom lookup based on fields in Form

Sample situation: Payment category field need to filter based on Sales Order sales type (SalesTable.AvSalesType).
 If sales type == sales contract then filter payment category where AvTurnIn == Yes.
If sales type == service invoice then filter payment category where AvServiceInvoice == Yes.

Code:
Override AvPayment.AvPaymentCategory.lookup().

public void lookup(FormControl _formControl, str _filterStr)
{
    Query query = new Query();
    QueryBuildDataSource queryBuildDataSource;
    QueryBuildRange queryBuildRange;
    SysTableLookup sysTableLookup = SysTableLookup::newParameters(tableNum(AvPaymentCategory), _formControl);
    sysTableLookup.addLookupField(fieldNum(AvPaymentCategory, AvPaymentCateogry));
    sysTableLookup.addLookupField(fieldNum(AvPaymentCategory, Description));
    queryBuildDataSource = query.addDataSource(tableNum(AvPaymentCategory));

    if (SalesTable.AvSalesType == AvSalesType::SalesContract)
    {
        queryBuildRange = queryBuildDataSource.addRange(fieldNum(AvPaymentCategory, AvTurnIn));
    }
    else
    {
        queryBuildRange = queryBuildDataSource.addRange(fieldNum(AvPaymentCategory, AvServiceInvoice));
    }

    queryBuildRange.value('1');

    sysTableLookup.parmQuery(query);
    sysTableLookup.performFormLookup();

}

Monday, March 31, 2014

How to use Code Table create Enum

1. Go to Form AvCodeTable to create the new code:


2. Create new EDT extend from AvCodeTable:

3. a) Create Table References:


    b) Create filter Value 5 (select value filter from the Form AvCodeTable field Code type ID refer to step 1) :

4. Add the field to Table:


5. Add relation 




6. Able to browse it at table now:








Monday, March 24, 2014

Adding FileNameOpen Extended Data Type to a Form

After add EDT FileNameOpen to form using New -> stringEdit, 



add some form methods:

str fileNameLookupFilename()
{
    return '';
}

str fileNameLookupTitle()
{
    return "@SYS53008";
}

str fileNameLookupInitialPath()
{
    return '';
}

container fileNameLookupFilter()
{
    return ['All files','*.*'];
}

After get the file path, call insert method:

public void AvInsertAttachment(filename file, int i)
{    
    DocuRef docuRef;
    DocuActionArchive archive;
    ;           
    
    if(file)
    {
        ttsbegin;
        docuRef.clear();
        docuRef.RefRecId = DirPartyEntity.RecId;
        docuRef.RefTableId = tableNum(CustTable);
        docuRef.RefCompanyId = DirPartyEntity.dataAreaId;
        docuRef.Name = strFmt("Consultant Attachment %1", i);
        docuRef.TypeId = 'File';
        docuRef.insert();
        archive = new DocuActionArchive();
        archive.add(docuRef, file);
        ttsCommit;
    }
}

Result:





Thursday, March 6, 2014

Job to update customer financial dimension in dynamics ax 2012

static void setFinancialDimensionToCustomer(CustAccount _custAccount)  
 {  
  CustTable custTable;  
  Struct struct = new Struct();  
  container ledgerDimension;  
  DimensionDefault DimensionDefault;  
  ;  
  struct.add('BookingChannel', '30');  
  struct.add('Carrier', '01');  
  struct.add('Department', '30');  
  struct.add('Destination', '01');  
  struct.add('Division', '30');  
  struct.add('Origin', '01');  
  struct.add('Product', '30');  
  ledgerDimension += struct.fields();  
  ledgerDimension += struct.fieldName(1);  
  ledgerDimension += struct.valueIndex(1);  
  ledgerDimension += struct.fieldName(2);  
  ledgerDimension += struct.valueIndex(2);  
  ledgerDimension += struct.fieldName(3);  
  ledgerDimension += struct.valueIndex(3);  
  ledgerDimension += struct.fieldName(4);  
  ledgerDimension += struct.valueIndex(4);  
  ledgerDimension += struct.fieldName(5);  
  ledgerDimension += struct.valueIndex(5);  
  ledgerDimension += struct.fieldName(6);  
  ledgerDimension += struct.valueIndex(6);  
  ledgerDimension += struct.fieldName(7);  
  ledgerDimension += struct.valueIndex(7);  
  ttsBegin;  
  DimensionDefault = AxdDimensionUtil::getDimensionAttributeValueSetId(ledgerDimension);  
  custTable = CustTable::find(_custAccount, true);  
  custTable.DefaultDimension = DimensionDefault;  
  custTable.update();  
  ttsCommit;  
 }  

Thursday, February 6, 2014

A call to the Microsoft Dynamics AX SRSFramework Service service failed. An existing connection was forcibly closed by the remote host.


Issues related to AXRDCE are often resolved by deleting the AUC files
  1. Stop reporting services,
  2. Goto: C:\Users\xxx\AppData\Local\ ( may in difference path like D:\ E:\)
  3. Take the backup of all AUC files,
  4. Remove them from there
  5. Start reporting services
* Another problem may face is may have multiple ax service in multiple server, try to start all the ax first only process the element deployment (ssrs report element deploy).

Can't view the image/picture in ESS report using IE browser, but can view in Firefox



Try to change the MIME type in Visual studio image properties.

Access denied to field Partition (Partition) in table XXXX...


The problem should be no add the table in Permissions Privileges. Example:



Thursday, January 23, 2014

How to save the SSRS report to PDF/HTML through code in dynamics ax 2012.

SrsReportRun srsReportRun; srsReportRun = new SrsReportRun("InventTruckTransactionReport.PrecisionDesign1"); srsReportRun.init(); srsReportRun.reportCaption("InventTruckTransactionReport.PrecisionDesign1"); srsReportRun.reportParameter("TruckTransDS_JournalId").value("000161_070"); srsReportRun.showDialog(false); // Print to a file named ReportExample in HTML/PDF format. srsReportRun.printDestinationSettings().printMediumType(SRSPrintMediumType::File); srsReportRun.printDestinationSettings().fileFormat(SRSReportFileFormat::PDF); srsReportRun.printDestinationSettings().overwriteFile(true); srsReportRun.printDestinationSettings().fileName(@"C:\InventTruckTransactionReport.pdf"); if( srsReportRun ) { srsReportRun.executeReport(); }

How to print the SSRS report in dynamics ax 2012 from code.

SrsReportRun srsReportRun; // initiate the report. srsReportRun = new SrsReportRun ("InventTruckTransactionReport.PrecisionDesign1"); srsReportRun.init(); srsReportRun.reportCaption("InventTruckTransactionReport.PrecisionDesign1"); // set parameters name, value. srsReportRun.reportParameter("TruckTransDS_JournalId").value("000161_070"); // suppress the dialog srsReportRun.showDialog(false); if( srsReportRun ) { // run the report srsReportRun.executeReport(); }

Wednesday, January 15, 2014

DMF Error During Import

DMF Error During Import. System.ServiceModel.ProtocolException: The remote server returned an unexpected response: (502) Bad Gateway. ---> System.Net.WebException: The remote server returned an error: (502) Bad Gateway. at System.Net.HttpWebRequest.GetResponse() at System.ServiceModel.Channels.HttpChannelFactory`1.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) --- End of inner exception stack trace --- Makesure the LAN SETTING of INTERNET CONNECTION is not hijacked or override by third party software, e.g. hotspot shield.