Alfasith AX

Alfasith AX
اللَّهُمَّ انْفَعْنِي بِمَا عَلَّمْتَنِي، وَعَلِّمْنِي مَا يَنْفَعُنِي، وَزِدْنِي عِلْمًا

Monday, December 25, 2017

Code to print form letter notes like Purchase Order notes, Sales Quotation etc in AX 2012

Hi,

 print FormLetterRemarks::find('en-us',FormTextType::ProjectQuotation).Txt;

viz, PurchaseOrderConformation

Regards,

Code to print attachment Notes in AX 2012

Hi,

static void Job75(Args _args)
{
    DocuRefSearch        docuRefSearch;
    SalesQuotationTable     quotationTable;
    quotationTable = SalesQuotationTable::find('CBI-000039');
    docuRefSearch = DocuRefSearch::newTypeIdAndRestriction(quotationTable, 'note', DocuRestriction::External);
           
    //    projActivityCostSummaryTmp.Notes                = Docu::concatDocuRefNotes(docuRefSearch);
    print Docu::concatDocuRefNotes(docuRefSearch);
    print DocuRef::find(quotationTable.dataAreaId,quotationTable.RecId).Notes;
    pause;
}

Regards

Saturday, December 16, 2017

Unretrieved Values in Grid AX 2012

Hi,

You may face this kind of error / bugs during newly added fields to the table.

Case 1:
If the record is Unretrieved in table level-  Sync issue
Solution:
Right click and select synchronize that concern table.

Case 2:
If it not let you to open that table
Solution:
Synchronize entire AOT.

Case 3.
If it says Unretrieved Values in Grid
Solution:
Restart the AOS.

Thanks & Regards,



Wednesday, November 22, 2017

From date and To date time conversion in AX 2012

Hi,

print  DateTimeUtil::newDateTime(fromDare,0);

This will return day start time 12:00 AM

print DateTimeUtil::newDateTime(ToDate,86400);

This will return day end time 11:59 PM

Regards,

Tuesday, November 21, 2017

Cannot insert the value NULL into column message in insert_recordset in AX 2012

Hi,

When you are trying to insert the insert the record in to a table using insert_recordset method in the case of joining to table either pulling from view or a query then we cannot assign null vaues.

Example:
2 tables are joined in view and some filed in child table values may not be available on join which will result in null, in that case we need to insert null values in target table using insert_recordset.

Solution:
Ignore those fields on insert_recordset selection later update if there is a record using update_recordset.

Sample.
In the below example Building,Community,Project,RetailStore,Unit  are dimension, so values may not come always.

insert_recordset custVendPDCTmp (LedgerDimension, JournalNum, PDCStatus, StopPayment, AmountCurCredit,
        AmountCurDebit, BankChequeNum, BankAccountId, CurrencyCode, DefaultDimension,
        LineNum,MaturityDate,
        PaymentStatus,PaymentRealizedStatus,Voucher,IsReplacementCheck
        // Building,Community,Project,RetailStore,Unit,
        )
        select LedgerDimension,JournalNum, PDCStatus,StopPayment,AmountCurCredit,
        AmountCurDebit,BankChequeNum,BankAccountId,CurrencyCode,DefaultDimension,
        LineNum,MaturityDate,
        PaymentStatus,PaymentRealizedStatus,Voucher,IsReplacementCheck
        //Building,Community,Project,RetailStores,Unit,
            from custVendPDCQueryView where custVendPDCQueryView.AccountType == accountType;

Solution:


update_recordSet custVendPDCTmp
        setting Building = custVendPDCQueryView.Building
        Join custVendPDCQueryView
        where custVendPDCQueryView.DefaultDimension == custVendPDCTmp.DefaultDimension &&            custVendPDCQueryView.Building != "";

Thursday, October 26, 2017

Conditional based decimal in SSRS

Hi,

=iif(Fields!CurrencyCode.Value ="USD",(FormatNumber(Fields!TotalAmountSumDebit.Value,2)),(FormatNumber(Fields!TotalAmountSumDebit.Value,4)))

Regards,

Tuesday, October 17, 2017

Find number of hits and data usage in SQL * Applicable for all the applications (SQL as DB)

Hi,

Right click on the DB and select script and page below one.

SELECT
tables.NAME AS TableName,
indexes.name as IndexName,
sum(partitions.rows) as NumberOfRows,
sum(allocation_units.total_pages) as TotalPages,
sum(allocation_units.used_pages) as UsedPages,
sum(allocation_units.data_pages) as DataPages,
(sum(allocation_units.total_pages) * 8) / 1024 as TotalSizeMB,
(sum(allocation_units.used_pages) * 8) / 1024 as UsedSizeMB,
(sum(allocation_units.data_pages) * 8) / 1024 as DataSizeMB
FROM
sys.tables
INNER JOIN     
sys.indexes ON tables.OBJECT_ID = indexes.object_id
INNER JOIN
sys.partitions ON indexes.object_id = partitions.OBJECT_ID AND indexes.index_id = partitions.index_id
INNER JOIN
sys.allocation_units ON partitions.partition_id = allocation_units.container_id
GROUP BY
tables.NAME, indexes.object_id, indexes.index_id, indexes.name
ORDER BY
TotalSizeMB DESC

Sunday, October 8, 2017

Checkbox in dialog in X++

static void DialogCheckBox(Args _args)
{
    Dialog      dialog                   = new Dialog("New dialog with checkBox");
    NoYesId     checkValue               = NoYes::No;
    str                         strMessage = "Confirmation will create Variation. \n Click OK to proceed.";
    str                         strTitle = "Confirmation of Project / Contract WBS";

    DialogField dialogFieldVariation     = dialog.addFieldValue(extendedTypeStr(NoYesId), checkValue, "Create variation");
    DialogField dialogFieldVariationType = dialog.addFieldValue(enumStr(ProjBudgetRevRequestorType), "","Variation type");
    DialogField dialogFieldVariationDiscription = dialog.addFieldValue(extendedTypeStr(Description), "" );
    dialog.caption("Confirmation of Project / Contract WBS");
    dialog.addText("Please check to create Variation. Click OK to proceed",0);
    if (dialog.run())
    {
        checkValue = dialogFieldVariation.value();
        if(checkValue)
            info("Hi");
        else
            info("Bye");
    }
}

Tuesday, September 26, 2017

An update conflict occurred due to another user process deleting the record or changing one or more fields in the record

Hi,


Record conflict errors.

You needs to block the records to your session these are the ways you can lock the table records.

1. ttsbegain and ttscommit will also plays this role.

2. OCCEnabled true the property in table level.

3. In X++

a. select statement.

 select pessimisticLock purchTable where purchTable.PurchId == "XXXXX";

b. recordset statement.

update_recordSet pessimisticLock purchLine setting
            RemainInventPhysical = 0,
            RemainPurchPhysical   = 0,
            PurchStatus           = PurchStatus::Canceled
            where purchLine.PurchId == purchTable.PurchId;


Thanks,
Alfasith

Tuesday, September 5, 2017

Override the action pane methods in List Page AX 2012

Hi,

Please change the Display Target properties to client instead of Auto  / EP to get the override methods.

Also this can be achieved by interaction class.

Regards,

Due date based alert Configuration in AX 2012

Hi,

1. Create a a date field.
2. Right click in form level and select create alerts.
3. Select due in in the pop up.
4. Select the email alert notification and no end time.  // Now records get created in Event Table.
5. Select Organisation Administration \ Setup \Alert  view details create the email template.
6. Define the batch group for that batch.
7. System Administration \ Periodic \Alert \ Due date click.
8. Run the Tutorial_EventProcessor form.



Note: Please make sure that you enable the batch processing and email alert in the batch in point 7.

Thanks

Alert customization - Getting a table details in email AX 2012

Hi,

Please check for customization in EventActionEmail\createEmailParameterMap class

%data% will print the available notification message.
%Message% will print the information event Table.


You may add your values in createEmailParameterMap  map method of EventActionEmail class.

Regards,

Friday, June 30, 2017

Print table name by table id in AX 2012

Hi,

static void TableAOTName(Args _args)
{
    print tableId2Name(615);
    pause;
}


static void TableName(Args _args)
{
    print tableId2PName(615);
    pause;
}




Sunday, May 14, 2017

Print management in AX 2012

Hi,

There are 2 set of tables associated to Print management
1. Default
2 Print management design.

1. Default will be called by class\PrintMgmtDocType\methods\getDefaultReportFormat where as we can change this values in form setup form level.

2. For Print management on customized design called by
Tables - PrintMgmtReportFormat\Methods\populate

addOther(PrintMgmtDocumentType::SalesOrderPackingSlip, ssrsReportStr(SalesPackingSlip, ReportUD), ssrsReportStr(SalesPackingSlip, ReportInternational), #NoCountryRegionId);

Here ReportInternational is my design name.

Then run the populate method will create a record in PrintMgmtReportFormat with your new design as same document type that you mentioned in the above added code.

if you want change this design as default please change by manual in Form setup (of concern module)\ print management.

Hope you enjoyed,
Regards,


Sunday, April 9, 2017

FCB::Open failed: Could not open file D:\TempDB\tempdb.mdf for file number 1. OS error: 3(The system cannot find the path specified.). SQL 2014

Hi,

Either of these below error persist in the SQL service stop then you need to check the Database location exist. (Particularly tempdb).

Initializing the FallBack certificate failed with error code: 1, state: 20, error number: -2146893788.

Unable to initialize SSL encryption because a valid certificate could not be found, and it is not possible to create a self-signed certificate.

TDSSNIClient initialization failed with error 0x80092004, status code 0x1. Reason: Initialization failed with an infrastructure error. Check for previous errors. Cannot find object or property.

SQL Server could not spawn FRunCommunicationsManager thread. Check the SQL Server error log and the Windows event logs for information about possible related problems.

Solution:
1. Needs to check the existence of D:\TempDB\tempdb.mdf directory and file.
2. If not please create directory and then start the service.
3. Hope Service will get started. Then please change the directory location from the temporary drive to permanent drive.
This is a common issue in Azure temporary drive.
4. Change the directory of the master / physical DB through sp_helpfile.
  Consider we needs to change the location of D\TempDB to E\TempDB.
a. Using CMD prompt run as administrator select the directory of SQL installed.

default location:
cd C:\Program Files\Microsoft SQL Server\MSSQL12.MSSQLSERVER\MSSQL\Binn 

then following the following commands.

 SQLCMD -s .  
Please make sure you have (dot) .  at the end of this command.

SELECT name, physical_name, state_desc FROM sys.master_files ORDER BY database_id;
GO

Please check ion which location actually it locates to.
then select the DB and new location that you want to move the DB file.

ALTER DATABASE tempdb MODIFY FILE ( NAME = tempdev, FILENAME = 'E:\SQL\TempDB\tempdb.mdf');
GO
ALTER DATABASE tempdb MODIFY FILE ( NAME = templog, FILENAME = 'E:\SQL\TempDB\templog.ldf');
GO

Regards,


Wednesday, January 25, 2017

Code to get WBS and Summary cost and sales estimates of an smmActivity

public static void SummarySalesPriceEstimates()
{

    ProjWBSUpdateController                 controllerLoc;
    HierarchyIdBase                         hierarchyIdLoc;
    HierarchyTreeTable                      hierarchyTreeTableLoc;
    str                                           recordWBSId;
    smmActivities                           smmActivitiesLoc;
    ProjTable                               projTableLoc;
    CalendarId                              calendarIdLoc;
    PSAActivityEstimates                    localPSAActivityEstimates;
    HierarchyTreeTable                      localHierarchyTreeTable;
    smmActivities                           localSmmActivities;
    HierarchyPath                           descendantsRangeValue;
    SalesPrice                              summarySalesPriceLoc;
    CostPrice                               summaryCostPriceLoc;

    #Characters

    descendantsRangeValue = hierarchyTreeTable.Path + hierarchyTreeTable.ElementNumber + #sharp + "*";

    smmActivities = smmActivities::find("CDC-008005");
    hierarchyTreeTableLoc = hierarchyTreeTable::findRefRecId(smmActivities.RecId);

    calendarId = ProjTable::find(smmActivities.projId()).PSASchedCalendarId;

    hierarchyId = hierarchyTreeTable.HierarchyId;

    controller = new ProjWBSUpdateController(hierarchyId,calendarId);
    controller.updateOutlineNumbersAndPublishInPreOrder();
    recordWBSId = controller.outlineNumberFor(hierarchyTreeTable.ElementNumber);
    if (!controller.hasChildren(hierarchyTreeTable))
    {
        // Get sum for the task itself.
        select sum(TotalSalesPrice), sum(TotalCostPrice) from localPSAActivityEstimates
            where localPSAActivityEstimates.ActivityNumber == smmActivities.ActivityNumber;

        summarySalesPrice = localPSAActivityEstimates.TotalSalesPrice;
        summaryCostPrice = localPSAActivityEstimates.TotalCostPrice;
    }
    else
    {
        // Include sum for the selected summary task's descendents.
        select sum(TotalSalesPrice), sum(TotalCostPrice) from localPSAActivityEstimates
            join RecId from localSmmActivities
                where localSmmActivities.ActivityNumber == localPSAActivityEstimates.ActivityNumber
                join RecId from localHierarchyTreeTable
                    where localHierarchyTreeTable.RefRecId == localSmmActivities.RecId
                          && localHierarchyTreeTable.Path like descendantsRangeValue;

        summarySalesPrice = localPSAActivityEstimates.TotalSalesPrice;
        summaryCostPrice = localPSAActivityEstimates.TotalCostPrice;
    }
    info(recordWBSId);
    info(strFmt("%1-%2",summarySalesPrice,summaryCostPrice));

}

Dimension Lookup for both standard and Custom dimension in D365

Hi,  /// <summary>     /// Provides the look-up interaction for the individual dimension value lookup controls.     /// </summary&g...