Monday, December 23, 2019

The supplied SnapshotPoint is on an incorrect snapshot! in VS 2015 for D365FO

Error: The supplied SnapshotPoint is on an incorrect snapshot! in VS 2015 for D365FO

The supplied SnapshotPoint is on an incorrect snapshot! in VS 2015 for Microsoft Dynamics 365 For Finance and operations

The supplied SnapshotPoint is on an incorrect snapshot.


Solutions: Open VS 2015
Tools>Options:

Open VS 2015
Tools>Options

Go to Text Editor> X++ and then uncheck word wrap and show visual glyphs for word wrap.
















Wednesday, December 18, 2019

Maintenance mode in D365FO


All users need to sign out from D365FO.
Only Maintenance mode user and system admin can login into D365FO once maintenance mode activated. 

Enable Maintenance mode in cloud hosted VM

K:\AosService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.AX.Deployment.Setup.exe --metadatadir K:\AosService\PackagesLocalDirectory --bindir K:\AosService\PackagesLocalDirectory\Bin --sqlserver . --sqldatabase axdb --sqluser axdbadmin --sqlpwd ********* --setupmode maintenancemode --isinmaintenancemode true
  
IISRESET

Signout and sign in the browser.

Disable maintenance mode in cloud hosted VM

K:\AosService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.AX.Deployment.Setup.exe --metadatadir K:\AosService\PackagesLocalDirectory --bindir K:\AosService\PackagesLocalDirectory\Bin --sqlserver . --sqldatabase axdb --sqluser axdbadmin --sqlpwd ******** --setupmode maintenancemode --isinmaintenancemode false
  
IISRESET

Signout and sign in the browser.

Enable Maintenance mode in local VM
C:\AosService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.AX.Deployment.Setup.exe --metadatadir C:\AosService\PackagesLocalDirectory --bindir C:\AosService\PackagesLocalDirectory\Bin --sqlserver . --sqldatabase axdb --sqluser AOSUser --sqlpwd AOSWebSite@123 --setupmode maintenancemode --isinmaintenancemode true

IISRESET


Signout and sign in the browser.

Disable Maintenance mode in local VM
C:\AosService\PackagesLocalDirectory\Bin\Microsoft.Dynamics.AX.Deployment.Setup.exe --metadatadir C:\AosService\PackagesLocalDirectory --bindir C:\AosService\PackagesLocalDirectory\Bin --sqlserver . --sqldatabase axdb --sqluser AOSUser --sqlpwd AOSWebSite@123 --setupmode maintenancemode --isinmaintenancemode false

IISRESET

Signout and sign in the browser.

Sunday, December 15, 2019

Turn off / On all services in D365FO

Turn off all the D365F&O services in DEV VM


To turn off all the D365F&O services
1. Open PowerShell as an administrator mode
2. Type "stop-d365environment"
3. click -> Enter


To turn on all the D365F&O services
1.Open PowerShell as an administrator mmode
2.Start-d365environment
3.Click -> Enter

Wednesday, December 11, 2019

Uninstall package from deployable package in D365FO


  • Take zip file of the deployable package that needs to be removed and unzip it (C:\Users\Administrator\Desktop\eployablePackage)
  • Navigate to C:\Users\Administrator\Desktop\DeployablePackage\AXDeployablePackage_20191212_11_13_50\AOSService\Scripts folder
    • Create a text file called ModuleToRemove.txt,
    • Enter the package you like to remove from the deployable package
    • If you have multiple packages, enter the package name one by one (one package name per one line)

  • Navigate to C:\Users\Administrator\Desktop\DeployablePackage\AXDeployablePackage_20191212_11_13_50\AOSService\Packages folder
    • Delete the .nupkg files from this folder
    • dynamicsax-mypackage1.7.0.5372.35448.nupkg
    • dynamicsax-mypackage2.7.0.5372.35448.nupkg
  • Navigate to C:\Users\Administrator\Desktop\DeployablePackage\AXDeployablePackage_20191212_11_13_50\AOSService\Packages\files folder

    • In this folder each package one zip file will be created
    • Delete the package zip file which one you want to remove
  • In the root deployable package directory, modify the HotfixInstallationInfo.xml file to remove references to the modules you are removing,
  • specifically under the following XML tags:
    • MetadataModuleList
    • AllComponentList -> ArrayOfString
  • After modification the file will be look like this
  • Rezip the deployable package, upload it to LCS in the asset library, and deploy it like you would any other deployable package
Prerequisites
  • If any models reference the module that will be removed, the references must be removed from them. For information about how to find the references that must be removed, see Viewing model dependencies.
  • Build and deploy any modules that references were removed from.
  • All references to and from the modules must be removed before you begin to uninstall the module. To remove all a module's references, add a single class to the model. This class should contain no code. It should contain only a reference to the application platform.
Notes
  • Deployable packages only reference the platform build within the metadata, so you only need to build one package per platform version
  • Be sure to not change the folder structure when you are unzipping or rezipping the deployable package, this will cause the validation process to fail when uploading it back into LCS

D365FO On premises AOS service restart

This powershell script would be run from one of the orchestrators and the AOS node names are AOS_233 and AOS_234. Your node names will be different. The server common name should be the name for the client cert and the thumbprint FindValue should be the thumbprint for that cert.


$ConnectArgs = @{  ConnectionEndpoint = 'localhost:19000';  X509Credential = $True;  StoreLocation = 'CurrentUser';  StoreName = "MY";  ServerCommonName = "clientd365ffo.onprem.contoso.com";  FindType = 'FindByThumbprint';  FindValue = "11AAAA1111AA11A111A1AFA11011111A111AA110"   }
Connect-ServiceFabricCluster 
Restart-ServiceFabricDeployedCodePackage -NodeName "AOS_233" -ApplicationName fabric:/AXSF -CodePackageName "Code" -ServiceManifestName "AXSF" -CommandCompletionMode Verify
Restart-ServiceFabricDeployedCodePackage -NodeName "AOS_234" -ApplicationName fabric:/AXSF -CodePackageName "Code" -ServiceManifestName "AXSF" -CommandCompletionMode Verify


original post: http://www.atomicax.com/article/d365ffo-prem-aos-restart

Thursday, December 5, 2019

Clear Cache AOD flush in Dynamics 365 for finance and operations

https://[AOS NAME].cloudax.dynamics.com/?mi=SysClassRunner&cls=SysFlushAOD

or

https://[AOS NAME].cloudax.dynamics.com/?mi=action:SysFlushAOD

retrieve financial dimension values from fin dimension id

DimensionValue getDimensionValue(RefRecID dimensionSetRecID,Name attributeName)
{
 
    DimensionAttributeValueSet      dimAttrValueSet;
    DimensionAttributeValueSetItem  dimAttrValueSetItem;
    DimensionAttributeValue         dimAttrValue;
    DimensionAttribute              dimAttribute;
 
    dimAttrValueSet = DimensionAttributeValueSet::find(dimensionSetRecID);
 
    select dimAttrValueSetItem
        where   dimAttrValueSetItem.DimensionAttributeValueSet      == dimAttrValueSet.RecId
    join dimAttrValue  
        where   dimAttrValue.RecId                                  == dimAttrValueSetItem.DimensionAttributeValue
    join dimAttribute      
        where   dimAttribute.RecId                                  == dimAttrValue.DimensionAttribute
        &&      dimAttribute.Name                                   == attributeName;
 
    return dimAttrValue.getValue();      
}  

Sales line picking list

Sales line picking list


public static void RetailCWItemSalesLinePick(SalesLine salesLine)
        {
            TmpInventTransWMS       tmpinventTransWMS;
            InventTrans             inventTrans;
            InventTransWMS_Pick     inventTransWMS_Pick;
            Query                   inventTransQuery;
            QueryBuildDataSource    qbdsInventTrans;
            QueryBuildRange         qbRange;
            InventTransChildType    inventTransChildType;
            InventTransChildRefId   inventTransChildRefId;
            ItemFreeTxt             rangeStr;
            counter                 inventTransChildTypeInt;
            InventMovement          inventMovement;
            InventTransOriginId     inventTransOriginId;
   
            inventTransQuery = new Query();
   
            qbdsInventTrans = inventTransQuery.addDataSource(tableNum(inventTrans));
            qbdsInventTrans.addRange(fieldNum(InventTrans,StatusReceipt)).value(SysQuery::value(StatusReceipt::None));
            qbdsInventTrans.addRange(fieldNum(InventTrans,StatusIssue)).value(SysQuery::range(StatusIssue::Picked,StatusIssue::OnOrder));
   
            inventMovement      = InventTransWMS_Pick::inventMovement(salesLine);
            inventTransOriginId = inventMovement.inventTransOriginId();
   
            if (inventMovement)
            {
                if (inventMovement.transChildType())
                {
                    inventTransChildType  = inventMovement.transChildType();
                    inventTransChildRefId = inventMovement.transChildRefId();
                }
                else
                {
                    inventTransChildType  = InventTransChildType::None;
                    inventTransChildRefId = '';
                }
            }
            inventTransChildTypeInt = inventTransChildType; // Avoid query problems with special characters in enum label.
            //range over all loaded movements
            qbRange = qbdsInventTrans.addRange(fieldNum(InventTrans,InventTransOrigin));
            rangeStr = strFmt('((%1.%2 == %3) && (%4.%5 == %6)',
                            qbdsInventTrans.name(),
                            fieldStr(InventTrans,InventTransOrigin),
                            queryValue(inventTransOriginId),
                            qbdsInventTrans.name(),
                            fieldStr(InventTrans,TransChildType),
                            inventTransChildTypeInt);

            if (inventTransChildRefId)
            {
                rangeStr = rangeStr + strFmt(' && (%1.%2 == \"%3\"))',
                            qbdsInventTrans.name(),
                            fieldStr(InventTrans,TransChildRefId),
                            queryValue(inventTransChildRefId));
            }
            else
            {
                // To avoid 2 times double quotes for the childRefId.
                rangeStr = rangeStr + strFmt(' && (%1.%2 == \"\"))',
                            qbdsInventTrans.name(),
                            fieldStr(InventTrans,TransChildRefId));
            }
            qbRange.value(rangeStr);
   
            ttsBegin;
            inventTransWMS_Pick = InventTransWMS_Pick::newStandard(tmpinventTransWMS,inventTransQuery);
            inventTrans         = InventTrans::findTransId(salesLine.InventTransId);
   
            inventTransWMS_Pick.createFromInventTrans(inventTrans);
            tmpinventTransWMS   = inventTransWMS_Pick.parmTmpInventTransWMS();
   
            select firstOnly forUpdate tmpinventTransWMS where tmpinventTransWMS.InventTrans == inventTrans.RecId;
            tmpinventTransWMS.InventQty = salesLine.RemainInventPhysical;
            tmpinventTransWMS.update();
            inventTransWMS_Pick.writeTmpInventTransWMS(tmpinventTransWMS);
   
            inventTransWMS_Pick.updateInvent();
   
            ttsCommit;


        }


Pick the sales line which is unpicked earlier

Hi,

In my earlier post i have explained how to unpick the sales line which is the picking list registration is  already completed.

Here we see how to pick again the unpicked salesline and change status as Picked.

 private void pickSalesLine(SalesId _salesId)
    {
        InventTrans             inventTrans;
        InventTransOrigin       inventTransOrigin;
        WMSOrderTrans           orderTrans;
        InventTransWMS_Pick     inventTransWMS_Pick;
        Query                   query;
        QueryRun                queryRunInvTrans;
        TmpInventTransWMS       tmpInvTransWMS;
        InventDim               inventDimPick;
        InventDim               inventDimfind;
       QueryBuildDataSource    qbdsInventTrans;
        QueryBuildDataSource    qbdsWmsOrderTrans;
        QueryBuildDataSource    qbdsInventTransOrigin;         
         
 query = new Query();

 qbdsInventTrans = query.addDataSource(tableNum(InventTrans));
            qbdsInventTrans.addRange(fieldNum(InventTrans,StatusReceipt)).value(SysQuery::value(StatusReceipt::None));
            qbdsInventTrans.addRange(fieldNum(InventTrans,StatusIssue)).value(SysQuery::value(StatusIssue::OnOrder));
            qbdsInventTrans.addRange(fieldNum(InventTrans,StatusIssue)).value(SysQuery::value(StatusIssue::ReservPhysical));
qbdsInventTrans.addRange(fieldNum(InventTrans,TransChildType)).value(SysQuery::value(InventTransChildType::None));
        qbdsInventTrans.addRange(fieldNum(InventTrans,TransChildRefId)).value(SysQuery::value(strMin()));

            qbdsInventTransOrigin = qbdsInventTrans.addDataSource(tableNum(InventTransOrigin));
            qbdsInventTransOrigin.addLink(fieldNum(InventTransOrigin, RecId),fieldNum(InventTrans, InventTransOrigin));
            qbdsInventTransOrigin.joinMode(JoinMode::InnerJoin);
            qbdsWmsOrderTrans = qbdsInventTransOrigin.addDataSource(tableNum(WMSOrderTrans);
qbdsWmsOrderTrans .addLink(fieldNum(InventTransOrigin,InventTransId),fieldnum(WMSOrderTrans,InventTransId));
qbdsWmsOrderTrans .joinMode(JoinMode::InnerJoin);
qbdsWmsOrderTrans.addRange(fieldnum(WMSOrderTrans,TransRefId)).value(queryValue(_salesId));

            delete_from tmpInvTransWMS;
            inventTransWMS_Pick = InventTransWMS_Pick::newStandard(tmpInvTransWMS,query);
            queryRunInvTrans = new QueryRun(query);
            queryRunInvTrans.next();
            while(queryRunInvTrans.next())
            {
            inventTrans = queryRunInvTrans.get(tableNum(InventTrans));
            inventTransOrigin = queryRunInvTrans.get(tableNum(InventTransOrigin));
            inventDimPick = inventTrans.inventDim();
          //  inventDimPick.inventBatchId = "B001";
            inventDimPick = InventDim::findOrCreate(inventDimPick);
            tmpInvTransWMS.clear();
            tmpInvTransWMS.initFromInventTrans(inventTrans);
            tmpInvTransWMS.initFromInventTransOrigin(inventTransOrigin);
            tmpInvTransWMS.initFromInventDim(inventDimPick);
           // tmpInvTransWMS.InventQty = 5;
            inventTransWMS_Pick.writeTmpInventTransWMS(tmpInvTransWMS);
            inventTransWMS_Pick.updateInvent();
           }
         
        }
    }

Unpick sales line once picking list registration is completed

sometimes you need to unpick the salesline quanity once the sales order picking list generated.

There is two options available in standard from front end.

First option
1. Select the Sales order -> Picking list registrations -> Function -> Cancel picking route.
it will cancel the particular picking list details for that picking route id

Second option
2. Select the sales order -> select the Sales line -> Update line -> Pick
      a) select the sales line in the pop up form
      b) Confirm the sales line status is "picked"
      b) Click add picking line
      c) the line will be added in the bottom grid
      d) update the quantity with negative value
      e) The updated number of quantity will be changed as On order status

Please find below code to unpick all sales lines for the sales order irrespective of Picking list.

private void unPickSalesLines(SalesId _salesId)
    {
        InventTrans                            invTrans;
        InventTransWMS_Pick         inventTransWMS_Pick;
        Query                                     queryInvetTrans;
        QueryRun                              queryRunInvTrans;
        TmpInventTransWMS          tmpInvTransWMS;
        QueryBuildDataSource         qbdsInventTrans;
        QueryBuildDataSource         qbdsWmsOrderTrans;
        QueryBuildDataSource         qbdsInventTransOrigin;
        InventDimParm                     inventDimParmAllTransactions;

        // pick > add picking line
        queryInvetTrans = new Query();
        qbdsInventTrans = queryInvetTrans.addDataSource(tableNum(InventTrans));
        qbdsInventTrans.clearDynalinks();
        qbdsInventTrans.clearRanges();

  qbdsInventTrans.addRange(fieldNum(InventTrans,StatusReceipt)).value(SysQuery::value(StatusReceipt::None));
        qbdsInventTrans.addRange(fieldNum(InventTrans,StatusIssue)).value(SysQuery::value(StatusIssue::Picked));
qbdsInventTrans.addRange(fieldNum(InventTrans,TransChildType)).value(SysQuery::value(InventTransChildType::None));
        qbdsInventTrans.addRange(fieldNum(InventTrans,TransChildRefId)).value(SysQuery::value(strMin()));
        qbdsInventTransOrigin = qbdsInventTrans.addDataSource(tableNum(InventTransOrigin));
        qbdsInventTransOrigin.addLink(fieldNum(InventTrans, InventTransOrigin),fieldNum(InventTransOrigin, RecId));
        qbdsInventTransOrigin.joinMode(JoinMode::InnerJoin);
        qbdsWmsOrderTrans = qbdsInventTransOrigin.addDataSource(tableNum(WMSOrderTrans));
        qbdsWmsOrderTrans.addLink(fieldNum(InventTransOrigin, InventTransId),fieldNum(WMSOrderTrans, inventTransId));
        qbdsWmsOrderTrans.joinMode(JoinMode::InnerJoin);
        qbdsWmsOrderTrans.addRange(fieldNum(WMSOrderTrans, inventTransRefId)).value(SysQuery::value(_salesId));
        qbdsWmsOrderTrans.addRange(fieldNum(WMSOrderTrans, expeditionStatus)).value(SysQuery::value(WMSExpeditionStatus::Complete));

        inventDimParmAllTransactions.clear();

        inventTransWMS_Pick = InventTransWMS_Pick::newStandard(tmpInvTransWMS,queryInvetTrans);

        queryRunInvTrans = new QueryRun(queryInvetTrans);

        while(queryRunInvTrans.next())
        {
            invTrans = queryRunInvTrans.get(tableNum(InventTrans));
            inventTransWMS_Pick.createFromInventTrans(invTrans);
        }
       
        inventTransWMS_Pick.updateInvent();
 }

Sunday, December 1, 2019

Import and export model file in D365FO

In AX2012 we can import, export or delete the model files using axutil commands.

Like AX2012, we can Import, Export or delete the model files in D365FO using ModelUtil.exe command.

Open the command prompt window in Administrator mode

Navigate the following path

Navigate to the C:\AOSService\PackagesLocalDirectory\bin folder

Export model file

ModelUtil.exe -export -metadatastorepath=C:\AOSService\PackagesLocalDirectory -modelname="FleetManagement" -outputpath=c:\temp

Import model file

ModelUtil.exe -import -metadatastorepath=C:\AOSService\PackagesLocalDirectory -file="E:\Test\AppSuiteModernDesigns.axmodel"

Delete the model file

ModelUtil.exe -delete -metadatastorepath=C:\AOSService\PackagesLocalDirectory -modelname="FleetManagement"

Thursday, November 28, 2019

D365FO VM trail license expired

Microsoft releasing the D365FO VM,s with trail license, it automatically expire after 180 days.

Some cases we need to extend the trail license for some more days. Below comment will help you to extend the D365FO VM trail license.

  1.  Open the command prompt in Administrator mode (Command prompt Ã  Run as administrator)
  2. Execute the below comment to know current license details
    1. slmgr.vbs /dlv
  3. In order to extend the trail period, execute below command. 
    1. slmgr.vbs /rearm
  4. Restart the computer.
  5. The trail period is extended now.
  6. In order to check the trail period run the below command
    1. slmgr.vbs /dlv

Enable navigation bar in D365FO new version

Microsoft was removed the navigation bar in newer version of D365FO.

But many customer requested the navigation bar in D365FO. So microsoft brings the navigation bar as parameter setup in Client performance options forms.

If you required just enable the option in Client performance options

1.      Go to system administration > setup > Client performance options



 And Enable legacy navigation bar toggle.


Click Ok in the bottom of the page.

Refresh the browser. 

The legacy navigation bar will be available now.

Wednesday, November 27, 2019

SQL "IN" Operator

Microsoft Introduce IN Operator in X++ Syntax, but it will work with Enums  only.

Following are the example how you can use this

SalesTable  salesTable;
container   con = [SalesType::Sales,
SalesType::ReturnItem,
SalesType::Subscription];

while select SalesId from salesTable
where salesTable.SalesType in con
{
Info(salesTable.SalesId);
}