Microsoft.Dynamics.Ax.Xpp.ErrorException: Failed to create a session; confirm that the user has the proper privileges to log on to Microsoft Dynamics 365 for Finance and Operations.

Recently, applying binary updates to Tier-2 environment, IT department reported this issue to me, that it is failing at Step 20 with error :

“Microsoft.Dynamics.Ax.Xpp.ErrorException: Failed to create a session; confirm that the user has the proper privileges to log on to Microsoft Dynamics 365 for Finance and Operations.”

So this error is related to user privilege. Because DBSync runs under Admin365 user account. So it is essential to check this admin user privilege in correct table. And the correct table is UserInfo. So when I troubleshooted this issue, and checked UserInfo table, I found field ‘Enabled’ field value was 0. Means this admin user privilege was not enabled. So used this SQL query to update the field value.


select RecId from PARTITIONS where PARTITIONKEY = 'INITIAL'

select NETWORKALIAS,NETWORKDOMAIN,[SID],[Enabled]
from USERINFO
Where PARTITION = 5637144576 and ID = 'Admin'
begin tran
 update A
 Set A.ENABLE = 1
 From UserInfo A
 Where PARTITION = 5637144576 and ID = 'Admin'
rollback tran

Environment: Release 7.2 Update 12.

Posted in Dynamics AX 365 for operations | Leave a comment

Using Fiddler to check OData Entities

Environment – Dynamics 365 for finance and operations, Release 7.2, Update 12

So the big challenge for X++ developers is how to check the data entities that are published via customized code or even standard.

Use Fiddler.

Data entity property IsPublic = Yes, it means that data entity is accessible via OData. But data entity is accessible via public collection name. For example, Customers V2 entity (Target entity name is CustCustomerV2Entity) is accessible via OData as https://<axbaseurl>/data/CustomersV2

And if you have thousands of records, and you want filtered results, then you can add $filter criteria as well.

Example 1: If requirement is to list top 100 customers across all legal entities (assuming there exist more than one legal entity)

URL: https://<axbaseurl>/data/CustomersV2?$top=100&cross-company=true.

Example 2: If requirement is to list top 100 customers in just one legal entity.

URL: https://<axbaseurl>/data/CustomersV2?$top=100&$filter=dataAreaId eq ‘USMF’

Now there is a requirement to do some insert or update operation on a data entity. It is simple, yet, process driven.

Step 1. Authentication. For authentication, it is required to create an azure based application. Once this application creation is done, then you will get your ‘Client ID’ (or it is known as Application ID as well in azure portal for the application) and then you can generate (& Save) Client secret key as well. Both ‘ClientID’ and ‘Client Secret Key’ is required for Fiddler process.

Step 2. Registering and authorizing this application ID (or client ID) in Dynamics environment. Ensure that this ‘Client ID’ exist in Dynamics environment: Modules > System administration > Setup > Azure active directory applications. If record does not exist on the form, create a new one with details about Client ID, name:, and user Id. Ensure User ID = Admin.

Once you have above 2 steps completed, then you are ready for Fiddler action. It is once again 2 step process.

Step 1a. Get access_token, which is authorization key.

Step 2a. Use step 1 generated access_token in the GET or POST (insert operation) or PATCH (update operation) queries.

Step 1a. Get access_token query

POST https://login.windows.net/<tenantId>/oauth2/token HTTP/1.1
 Content-Type: application/x-www-form-urlencoded
 Host: login.windows.net

resource=https%3A%2F%2F<axbaseurl>&client_id=<clientId>&client_secret=<client_secret_key>&grant_type=client_credentials

<tenantId> – you can get this from Azure portal

<client_id> – as explained in Step 1 above. Client_Id or application Id is same.

<client_Secret_key> – As explained in Step 1 above.

How to use this step 1a in Fiddler?

  • Start Fiddler, and ensure that these settings are set appropriately.

Fiddler settings

  • Before ‘Options’ tab, there is ‘Scratch pad’. This is pretty awesome option where you can save your commands that can be selected and executed. The highlighted text is same as provided in step 1a above.

Get access_token

  •  Select the highlighted text, and click Execute button. The results would appear as given below. From here, you need to copy the value for tag “access_token” to be used in the next step with GET, POST or PATCH. Note that your scratch pad query is still available under “Composer” tab.

Access_token executed

  • Assume that you copied the access_token value.
  • Copy this access_token generated from previous screen and paste in the following query that you need to write in Scratch pad.
GET https://<axbaseurl>/data/Customers?$top=10&cross-company=true HTTP/1.1
OData-Version: 4.0
OData-MaxVersion: 4.0
Accept: application/json;odata.metadata=minimal
Accept-Charset: UTF-8
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IkZTaW11RnJGTm9DMHNKWEdtdjEzbk5aY2VEYyIsImtpZCI6IkZTaW11RnJGTm9DMHNKWEdtdjEzbk5aY2VEYyJ9.eyJhdWQiOiJodHRwczovL3N0YXJ0ZWNoZGV2YnJhbmNoYW9zLnNhbmRib3guYXguZHluYW1pY3MuY29tIiwiaXNzIjoiaHR0cHM6Leeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee2Q3YWYtYzM4Ni00YTJiLTg3YjAtMTZlNzZhZGRmYjIzLyIsImlhdCI6MTUyMjMwMjg5NCwibmJmIjoxNTIyMzAyODk0LCJleHAiOjE1MjIzMDY3OTQsImFpbyI6IlkyTmdZSGgzNE1XUmczZG03N2x2MVB5aitpZG5IZ0E9IiwiYXBwaWQiOiJkOGY2M2NmYi01MDgxLTQ3MTMtYWMyZS02OGIzZDYzMjYxZDQiLCJhcHBpZGFjciI6IjEiLxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxm5ldC8wYmYzZDdhZi1jMzg2LTRhMmItODdiMC0xNmU3NmFkZGZiMjMvIiwib2lkIjoiZDYwNzdkYzktNzczYS00MWE0LWFkNDAtMjBmZTI5MmMwNTFjIiwic3ViIjoiZDYwNzdkYzktNzczYS00MWE0LWFkNDAtMjBmZTI5MmMwNTFjIiwidGlkIjoiMGJmM2Q3YWYtYzM4Ni00YTJiLTg3YjAtMTZlNzZhZGRmYjIzIiwidXRpIjoiQ1hBWVZWMlpoMC0zTkZNM1M5TUpBQSIsInZlciI6IjEuMCJ9.pgf-hUFLhmadBVC8AXTmvP3IBROC-0tfF-qwYmdppkRbUj-xer-aPfB41Re41vtREOKAtMcmzQip7xtif7HnguDndh104hJZ9qHz-qp-zEQV4BCV-gb9pQw7LDvpwZNpGMGU6jrL2IYGdGTUcuhyNK2ePfInm5_TGpjiP_VKYUNcUZS-PUeGG6lqKL7oJlzlg6nTqbJJa3jXnCA0SbnSQwhyvgGVx97IGMqhQZ1MNNh3J5dHidL_8ubidwbP9FTjByC6rdtWsDWomJhDWe28zPbpS1CoClfvjewm1UII6j0PsPUc8hJwTjsZxmpfq__W9sZ5d7Be9TdqDlouof6vvg
Host: <axbaseUrl without https>
  • Select this whole text in scratch pad, and click ‘Execute’ button on top right. You will get the results as shown below:

Get Execute results

  • So in the result, you get JSON with top 10 customer records across all legal entities.

Example. Inserting (POST) a new customer postal address

Details: We extended the standard data entity ‘CustomerPostalAddressEntity’ to allow auto-generation of AddressLocationId field if not provided in the OData entity. And one more additional requirement to add ‘Telex Code’ in the address contact of type ‘Telex’. hence created a field called ‘STTelexCode’. The new entity name provided was “STCustomerPostalAddressEntity”. Command created in the scratch pad as follows. Bearer access_token is same as generated in step 1a above.

POST https://<axbaseurl>/data/STCustomerPostalAddresses HTTP/1.1
Authorization: Bearer eyJ0eXAiOiJKV1QiLCJJJJJJJJJJJJJJJJJJJJJJJJJTaW11RnJGTm9DMHNKWEdtdjEzbk5aY2VEYyIsImtpZCI6IkZTaW11RnJGTm9DMHNKWEdtdjEzbk5aY2VEYyJ9.eyJYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYYnNhbmRib3guYXguZHluYW1pY3MuY29tIiwiaXNzIjoiaHR0cHM6Ly9zdHMud2luZG93cy5uZXQvMGJmM2Q3YWYtYzM4Ni00YTJiLTg3YjAtMTZlNzZhZGRmYjIzLyIsImlhdCI6MTUyMjMwMjg5NCwibmJmIjoxNTIyMzAyODk0LCJleHAiOjE1MjIzMDY3OTQsImFpbyI6IlkyTmdZSGgzNE1XUmczZG03N2x2MVB5aitpZG5IZ0E9IiwiYXBwaWQiOiJkOGY2M2NmYi01MDgxLTQ3MTMtYWMyZS02OGIzZDYzMjYxZDQiLCJhcHBpZGFjciI6IjEiLCJpZHAiOiJodHRwczovL3N0cy53aW5kb3dzLm5ldC8wYmYzZDdhZi1jMzg2LTRhMmItODdiMC0xNmU3NmFkZGZiMjMvIiwib2lkIjoiZDYwNzdkYzktNzczYS00MWE0LWFkNDAtMjBmZTI5MmMwNTFjIiwic3ViIjoiZDYwNzdkYzktNzczYS00MWE0LWFkNDAtMjBmZTI5MmMwNTFjIiwidGlkIjoiMGJmM2Q3YWYtYzM4Ni00YTJiLTg3YjAtMTZlNzZhZGRmYjIzIiwidXRpIjoiQ1hBWVZWMlpoMC0zTkZNM1M5TUpBQSIsInZlciI6IjEuMCJ9.pgf-hUFLhmadBVC8AXTmvP3IBROC-0tfF-qwYmdppkRbUj-xer-aPfB41Re41vtREOKAtMcmzQip7xtif7HnguDndh104hJZ9qHz-qp-zEQV4BCV-gb9pQw7LDvpwZNpGMGU6jrL2IYGdGTUcuhyNK2ePfInm5_TGpjiP_VKYUNcUZS-PUeGG6lqKL7oJlzlg6nTqbJJa3jXnCA0SbnSQwhyvgGVx97IGMqhQZ1MNNh3J5dHidL_8ubidwbP9FTjByC6rdtWsDWomJhDWe28zPbpS1CoClfvjewm1UII6j0PsPUc8hJwTjsZxmpfq__W9sZ5d7Be9TdqDlouof6vvg
Content-Type: application/json; charset=utf-8
Host: <axbaseurl>

{ 
"CustomerAccountNumber": "Atul1012", 
"CustomerLegalEntityId": "US01", 
"AddressDescription": "hOME address1", 
"dataAreaId": "US01", 
"AddressCountryRegionId": "IND", 
"AddressLocationRoles": "Delivery", 
"AddressStreet":"Apurva Apartment complex,\n100 Block B, Apt 2011\n Near Ram Baazar",
"AddressState": "IN.10", 
"IsPostalAddress": "Yes", 
"IsPrimary": "No", 
"IsRoleBusiness": "No", 
"IsRoleDelivery": "Yes",
"STTelexCode": "ABCD123456" 
}

Select above POST query (all lines) and click ‘Execute’ button. The result screen shown below with status code 201: Created.

POST Created

 

More to come using PATCH later.

Happy Fiddling.

 

Posted in Data Entity, Dynamics AX 365 for operations, OData Protocol, Uncategorized | Leave a comment

D365 build warning on generate packages from VSTS

I saw this error in the “generate packages” build step when running automated build process from VSTS. The build process completes with warning status as “partially succeeded”. There are many steps on the job, but warning generates at “Generate packages” step.
Click on ‘Generate packages’ to see the log details:
Here is the warning snippet:


2018-03-14T23:04:51.7001491Z ##[section]Starting: Generate Packages
2018-03-14T23:04:51.7005985Z ==============================================================================
2018-03-14T23:04:51.7006123Z Task : PowerShell
2018-03-14T23:04:51.7006240Z Description : Run a PowerShell script
2018-03-14T23:04:51.7006341Z Version : 1.2.3
2018-03-14T23:04:51.7006442Z Author : Microsoft Corporation
2018-03-14T23:04:51.7006554Z Help : [More Information](https://go.microsoft.com/fwlink/?LinkID=613736)
2018-03-14T23:04:51.7006693Z ==============================================================================
2018-03-14T23:04:51.7035044Z ##[command]. 'C:\DynamicsSDK\GeneratePackage.ps1' -BuildPackagePath "C:\DynamicsSDK\VSOAgent\_work\1\Packages" -BuildBinPath "C:\DynamicsSDK\VSOAgent\_work\1\Bin" -BuildMetadataPath "C:\DynamicsSDK\VSOAgent\_work\1\s\Metadata" -BuildVersion "2018.3.14.2" -NoRuntime:([bool]0) -NoSource:([bool]0) -Verbose -ExclusionList "" -IncludeBinaries:([bool]1)
...
...
2018-03-14T23:11:56.0455875Z VERBOSE: 11:11:56 PM: - Foundation Upgrade: Exporting model source...
2018-03-14T23:11:56.0465237Z VERBOSE: 11:11:56 PM: - Command:
2018-03-14T23:11:56.0465605Z K:\AosService\PackagesLocalDirectory\Bin\ModelUtil.exe -export
2018-03-14T23:11:56.0465804Z -metadatastorepath="K:\AosService\PackagesLocalDirectory"
2018-03-14T23:11:56.0465938Z -modelname="Foundation Upgrade"
2018-03-14T23:11:56.0466101Z -outputpath="C:\DynamicsSDK\VSOAgent\_work\1\Packages\Source"
2018-03-14T23:11:56.8326946Z VERBOSE: 11:11:56 PM: Model Foundation Upgrade was not found in the specified
2018-03-14T23:11:56.8327660Z Metadata Store

2018-03-14T23:11:56.8337750Z VERBOSE: 11:11:56 PM: - Foundation Upgrade: Model export completed with exit
2018-03-14T23:11:56.8338146Z code: 1
2018-03-14T23:11:56.8475192Z VERBOSE: 11:11:56 PM: - Exception thrown at
2018-03-14T23:11:56.8475612Z C:\DynamicsSDK\GeneratePackage.ps1:216: throw "Error: Unexpected exit code from
2018-03-14T23:11:56.8475830Z model export: $ModelUtilExitCode"
2018-03-14T23:11:56.8475927Z
2018-03-14T23:11:56.8476073Z System.Management.Automation.RuntimeException: Error: Unexpected exit code from
2018-03-14T23:11:56.8476187Z model export: 1
2018-03-14T23:11:56.9558677Z ##[error]Write-Message : 11:11:56 PM: Error generating deployable packages: Error:
Unexpected exit code from model export: 1
At C:\DynamicsSDK\GeneratePackage.ps1:523 char:5
+ Write-Message "Error generating deployable packages: $($_)" -Erro ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorExcep
tion
+ FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorExceptio
n,Write-Message

Specific error: ‘Foundation upgrade’ model was not found in the specified MetaData store. So the first step is to identify this ‘Foundation upgrade.xml’ file existence in AosService location (K:\AosService\PackagesLocalDirectory). I searched this file and found it is \ApplicationSuite\Descriptor file location.

The problem exist in the “Foundation Upgrade” file. It seems that it is created by Microsoft in earlier days, and later they marked it ‘Disabled’ which you can find in the file that one element ‘Disabled’ is set to true. So during local compilation, metadata API process ignores the model where ‘Disabled’ element property is set to true. And because of this same property, model does not show up in the AOT as well. So when VSTS build tries to export this model, model utility (ModelUtil.exe) asks the metadata API for this model but it does not exist, hence this warning.

Solution: The quick fix is to remove this ‘Foundation upgrade.xml’ file from VSTS Source control. And essentially, this file should not be checked-in into source control. Generally, when we get ISV code (for example, Avalara or SKG), they sometime provide this file in the package. And when we check-in the code into VSTS, we include this file ‘Foundation upgrade.xml’ as well. So special caution is required when you check-in the code received from ISV, ensure that this ‘Foundation upgrade.xml’ is not exist, and if exist, you should not check it in into source control.

Happy building!!

Environment: Dynamics 365 for finance and operations, release 7.2, update 12.

Posted in Dynamics AX 365 for operations | Leave a comment

D365 OData query calls: examples

Working on Release 7.2, update 12 environments presently, recently I have been contacted by one of the client’s developer to query a specific customer record using OData.

Online documentation is very limited, it explains about appropriate syntax but lacks examples. So this article talks about the examples:

Example 1: Query one customer (DE-001) across one specific legal entity say ‘usmf’.

Filter URL: https://D365URL/data/Customers?$filter=CustomerAccount%20eq%20%27Atul1012%27&dataAreaId%20eq%20%27us01%27

In plain english, without encoding:

https://D365 URL/data/Customers?$filter=CustomerAccount eq 'DE-001'&dataAreaId eq 'usmf'

Example 2: Query a specific customer in ‘usmf’ legal entity:

URL: https://mysite.cloudax.dynamics.com/data/Customers(dataAreaId='usmf',CustomerAccount='DE-001')

Microsoft documentation exist: https://docs.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/data-entities/odata

But in addressing section, to query a single entity from the entity collection, the URL is [Your organization’s root URL]/data/Customers(“[Key]”) but without any examples.

Example 2 URL, for example, Customers data entity has just one primary key defined as ‘CustomerAccount’ but if you do not provide ‘dataAreaId’, it will not work. So ensure that ‘dataAreaId’ is provided.

Example 3. CustomerPaymentJournalLineEntity, this entity has 2 keys: JournalBatchNumber and LineNumber. Once again there are 2 ways to access it. Either use $filter or inline query.

Using $filter:

https://mysite.cloudax.dynamics.com/data/CustomerPaymentJournalLines?$filter=(JournalBatchNumber%20eq%20%2700003%27%20and%20LineNumber%20eq%204)

Without encoding: /data/CustomerPaymentJournalLines?$filter=(JournalBatchNumber eq ‘00003’ and LineNumber eq 4)

Using inline query:

I get an error when I use this URL:

 https://mysite.cloudax.dynamics.com/data/CustomerPaymentJournalLines(JournalBatchNumber='00003',LineNumber=4)

Error:

No HTTP resource was found that matches the request URI 'https://mysite.cloudax.dynamics.com/data/CustomerPaymentJournalLines(JournalBatchNumber='00003',LineNumber=4)'. 
No route data was found for this request.

Resolution: Change the URL to add ‘dataAreaId’.

So the new working URL is:

https://mysite.cloudax.dynamics.com/data/CustomerPaymentJournalLines(JournalBatchNumber='00003',LineNumber=4,dataAreaId='usmf')

That’s all for today!!

 

Posted in Dynamics AX 365 for operations, OData Protocol, Uncategorized | Leave a comment

D365: Workflow: Cannot start application

Dynamics 365 for finance and operations (Previously known as AX 7) is getting very interesting day by day. New features and tools are released with every new updates.

So I get a chance to work on workflows. D365FO has pretty interesting workflow designer that gets downloaded at runtime upon clicking on to a workflow. For example, Module Procurement and sourcing > Setup > Procurement and sourcing workflows. Assuming that workflow is already created in there, and assume the workflow name is “Purchase order workflow”. Now there is an error to this workflow. So as a developer, I click to it, and a run time application (of size about a little more than 7MB) gets downloaded to my machine, and  then workflow designer opens up. I fixed the issue, activated the new version after clicking ‘Save and close’. Pretty straight forward.

Now I wanted to experience or do it in different environment (different Azure VM), the experience is little different, where I encounter this issue – A nice little popup: Title – “Cannot start application” and message “Application cannot be started. Contact application vendor.” Two buttons: OK and Details… Click “Details…” opens up a notebook file that explains lot of technical details about the issue, but error summary is “Unable to install this application because an application with the same identity is already installed. To install this application, either modify the manifest version for this application or uninstall the preexisting application.”.

Error explains that applet (runtime application) already exist. Long story short, I figured that I can’t work on two workflows associated with two different URLs at the same time. So I investigated and found that these temporary files are stored in this location needs to be deleted manually before starting second workflow.

  1. Browse to location: C:\Users\<logged on username>\AppData\Local\Apps\2.0
  2. Here I saw 2 folders: Data and a folder with randon alphanumeric characters. In my case it was “KHGLL3L.ZBZ” (Jumbled characters).

To ensure that I am deleting right set of files (and not deleting something that may cause me an issue later), I get into this folder “KHGLL3L.ZBZ” continued till I reached to “manifests” folder and did open a file of type “manifest” in notepad++.  Line number 5 – 8 had <entryPoint> information that explains that these needs to be deleted because these are associated with previous version of workflow I ran from another environment.

<entryPoint>
<assemblyIdentity name=”Microsoft.Dynamics.AX.Framework.Workflow.WorkflowEditorHost” version=”7.0.0.0″ publicKeyToken=”31BF3856AD364E35″ language=”neutral” processorArchitecture=”amd64″ />
<commandLine file=”Microsoft.Dynamics.AX.Framework.Workflow.WorkflowEditorHost.exe” parameters=”” />
</entryPoint>

Finally I deleted all the folders from step 1 (above) location [C:\Users\<logged on username>\AppData\Local\Apps\2.0] and it was Shift Hold + Delete button.

Once all the files and folders deleted, I was able to start the workflow again from another Azure VM.

Solution #2: (Provided by colleague)

  1. Press the windows key and In search box type ‘cmd’ to find a command prompt
  2. Right click on the command prompt and select run as administrator
  3. Copy the command below, paste the command into the command prompt, and hit enter.

rundll32 dfshim CleanOnlineAppCache

Additional Notes:

  1. Workflow applet works only in Internet Explorer.
  2. Add URL as ‘Safe URL’ so that applet (runtime application) should not identify it “unsafe” and download should initiate smoothly.
  3. I don’t need to delete folder content if I need to work on workflows only in one environment all the time. If I get this specific error, then only I delete the folder content.

 

 

 

 

 

 

Posted in Dynamics AX 365 for operations, Uncategorized, Workflows | Leave a comment

D365FO: Warning: This product cannot be sold to the customer due to the product filter settings for this customer

During an integration process of a sales order line, my client received this error and integration failed. Actual error was –

{
“error”:{
“code”:””,”message”:”An error has occurred.”,”innererror”:{
“message”:”Write failed for table row of type ‘SalesOrderLineEntity’. Infolog: Warning: This product cannot be sold to the customer due to the product filter settings for this customer.; Warning: validateField failed on field ‘SalesOrderLineEntity.ItemNumber’.”,”type”:”Microsoft.Dynamics.Platform.Integration.Services.OData.AxODataWriteException”,”stacktrace”:”   at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.UpdateProcessor.CreateEntity_Save(ChangeOperationContext context, ChangeInfo changeInfo)\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.UpdateManager.<>c__DisplayClass5_0.<CreateEntity>b__1(ChangeOperationContext context)\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.ChangeInfo.ExecuteActionsInCompanyContext(IEnumerable`1 actionList, ChangeOperationContext operationContext)\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.ChangeInfo.TrySave(ChangeOperationContext operationContext)\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.UpdateManager.SaveChanges()\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.AxODataDelegatingHandler.<SaveChangesAsync>d__2.MoveNext()”
}
}
}

If the Product filters are configured correctly then this integration would have worked, but simply enabling a flag would simply break the integration. And that’s what happened in this case.

The flag was enabled (in the screen shot it is disabled because I did disable it).

Product filters

A relevant article I found online:

https://community.dynamics.com/enterprise/f/759/t/224279

And this article is further referring to AX 2012 R3 based article (pretty good information though)

http://dynamicsaxcompanions.azurewebsites.net/Tips-Tricks-Archive/Use-Filters-To-Restrict-Sellable-Products-To-Customers

 

Posted in Dynamics AX 365 for operations, Uncategorized | Leave a comment

D365FO: The menu item with name inventabcupdate could not be opened.

In Dynamics 365 for operations, platform update 7, it was reported to me by my team member that they are getting following error upon running ABC Classification period task from Inventory management > Periodic tasks section.
The menu item with name inventabcupdate could not be opened.
Session ID:840b4e5c-1869-4180-953e-5a2d043ef9df
Activity ID:bd183dd7-e5c1-4acb-90a2-3330cbbedf8f
Search timestamp:2017-06-12T20:51:39.899Z

Apparently, user interface screen is not showing a proper error message. Upon debugging, I found proper error in visual studio:
Microsoft.Dynamics.Ax.Xpp.ErrorException was unhandled by user code
Message: An exception of type 'Microsoft.Dynamics.Ax.Xpp.ErrorException' occurred in Dynamics.AX.ApplicationSuite.36.netmodule but was not handled in user code
Additional information: ABC classification ABC classification Total value is 0.00 USD.

Reproduction of the error

I looked further into the classes, and found the details, basically the query that was running behind the scene. Based on the parameters defined in the ABC classification periodic task form, code runs the following query behind the scene (assuming from date value is ’06/01/2017′ and to date value is ’06/30/2017′), and ABC model value is ‘Revenue’.
select A.itemId, A.ItemType, A.ABCCONTRIBUTIONMARGIN, A.ABCREVENUE,a.ABCTIEUP,a.ABCVALUE, B.INVOICEDATE, b.LINEAMOUNT, b.LINEAMOUNTMST
from InventTable A
right join CustInvoiceTrans B
on A.itemid = b.ITEMID
where A.DATAAREAID = 'usmf' and a.ITEMTYPE 2
and B.INVOICEDATE >= '06/01/2017' and B.INVOICEDATE <= '06/30/2017'

This query will not result any record as I dont have any customer invoices exist in this date range.

Fix

The only issue is that error/exception generated is not intuitive and is not presented nicely on the form. I will be working on it later.

How to run this period task successfully?

Well find out customer invoices data range, for example, when I run following query in SQL, I get lot of results. I provide this date range on the screen form, and it does run it correctly.
select A.itemId, A.ItemType, A.ABCCONTRIBUTIONMARGIN, A.ABCREVENUE,a.ABCTIEUP,a.ABCVALUE, B.INVOICEDATE, b.LINEAMOUNT, b.LINEAMOUNTMST
from InventTable A
right join CustInvoiceTrans B
on A.itemid = b.ITEMID
where A.DATAAREAID = 'usmf' and a.ITEMTYPE 2
and B.INVOICEDATE >= '06/01/2014' and B.INVOICEDATE <= '06/30/2015'

Once again, you can chose any value from ABC model drop down on the form. So above query update items: 4401, T0001 and so on.
The values are appropriately updated in ‘Released Product’ > select a product > Manage costs (fast tab) > ABC classification (section).

More technical details:

On ABC Classification user form,

  • clicking of ‘OK’ button calls and execute inventabcupdate.xpp menu item class. execution starts with run() method.
  • it further calls InventABC.calc() method. InventABC.xpp class’s calc() method further calls sumUpValue() method. This method is implemented in the extended classes based on ‘ABC model’ selected. For example, there are extended classes for each modal. For example, InventABC_Revenue.xpp extends InventABC for ABCModel=Revenue, InventABC_InventValue.xpp extends InventABC for ABCModel=Value, InventABC_CarrCost.xpp extends InventABC for ABCModel=Link and finally, InventABC_ContributionMargin.xpp extends InventABC for ABCModel=Margin.

All these extended classes run the make following query to check the list of items in the selected date range –
{Query InventTable object 96a1ef50: SELECT FORUPDATE * FROM InventTable(InventTable) ORDER BY InventTable.ItemId ASC WHERE ((ItemId = N'D0004')) AND ((NOT (ItemType = 2))) OUTER JOIN * FROM CustInvoiceTrans(CustInvoiceTrans_1) ON InventTable.ItemId = CustInvoiceTrans.ItemId AND ((InvoiceDate>={ts '2017-06-01 00:00:00.000'} AND InvoiceDate<={ts '2017-06-09 00:00:00.000'}))}
And then it can finally be converted into the following query:
select A.itemId, A.ItemType, A.ABCCONTRIBUTIONMARGIN, A.ABCREVENUE,a.ABCTIEUP,a.ABCVALUE, B.INVOICEDATE, b.LINEAMOUNT, b.LINEAMOUNTMST
from InventTable A
right join CustInvoiceTrans B
on A.itemid = b.ITEMID
where A.DATAAREAID = 'usmf' and a.ITEMTYPE 2
and B.INVOICEDATE >= '06/01/2017' and B.INVOICEDATE <= '06/09/2017'

By the way, above query will result to the error as I don’t have any invoices in this date range.

I only explained about the mitigation actions here. Essentially, this error should be presented to user in more meaningful way so that user could take an action to fix the issue.

 

 

Posted in Dynamics AX 365 for operations, Form exception, User Form | Leave a comment

Entity Publishing Error in Dynamics 365 for Operations

Dynamics 365 for Operations (formerly known as AX 7) has a feature of exporting data based on data entities on to Azure SQL Database for reporting purposes. It is very cool feature where there was a lot of demand from customers who would like to do data analysis using external reporting tools including (but not limited to) Power BI. Power BI can’t connect to cloud based AX databases so exporting data using data entities is a nice and cool feature.

For publishing, it is required to enable the change tracking on Data Entities. This is first step. Second step is to publish the entity schema on to Azure SQL Database. This Azure SQL database subscription needs to be purchased separately.

I was facing an issue where publishing of schema was failing because of following error:

Could not load file or assembly ‘Microsoft.SqlServer.Smo, Version=13.100.0.0. Please note that this error appears on AX’s base version 7.1 onward. It means version prior to rename of ‘Dynamics 365 for Operations’ works fine with publishing.

I had to open a Microsoft Ticket for this issue, and there is a hotfix available. It can be downloaded from here. Hotfix KB number is KB 3211228.

As per Microsoft Support, the real issue exist in the Entity.Method as DMFEntityDbPublish.publishSchema() where a chain of DLLs reference to this Microsoft.SqlServer.smo.dll version 13.100.0.0 which actually don’t exist in GAC or machine.

Once this hotfix is applied, the problem goes away.

Symptom:

Encounter the following error when publishing any entity

Could not load file or assembly ‘Microsoft.SqlServer.Smo, Version 13.100.0.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91’ or one of its dependencies. The system cannot find the file specified

Cause: Known issue

Resolution:

Patch KB3211228

 

Posted in Data Entity, Dynamics AX 365 for operations | Tagged , , | 19 Comments

Create a Site Collection and Apply Custom Site Template

Applicable to SharePoint 2010 On-premise based site collection.

Step 1 – Save Site Template.

First step is to save the site template locally that you would want to apply on the new site collection.


Now proceed to creating of managed path from SharePoint Central Administration.

Step 2 – Create Managed Path from SharePoint Central Administration

  • Visit to Central Administration http://centraladminmachine:port/_admin/webapplicationlist.aspx
  • Click to the web application: https://share.Company.com
  • Click Managed Paths from Office Ribbon.


  • A Define Managed Paths pop-up will appear. There you need to define an Path as /SampleWeb. Make sure that you define the path as forward slash (/) appended by SiteName you want to use.

    Second Type should be selected as Explicit inclusion.

  • When you click Add Path button, then window should look like the following window. Make sure that sampleweb has been added as Explicit inclusion.


  • Click OK button to close the window.
  • Now click Application Management on the left.

  • Click Create a site collection.

  • Define entries as given below:

  • Entries Detail:
    • Web Application – Make sure that correct web application is selected. In production one, it should be https://share.Company.com/
    • Title & Description – Define as per requirement.
    • Web Site Address – here you need to select the Managed Path you created. For example, /SampleWeb should be visible. You must select the correct URL.
    • Template Selection – Click Custom Tab to select the template later.
    • Primary Site Collection Administrator – Define Yours
    • Secondary Site Collection Administrator – Define secondary administrator.
    • The last entry is Quota – let it be no quota.


    • Click OK to close the window, but actually it will be creating the site collection.


  • In a while, you should able to see following window.

  • Click Ok, and it will take you back to Application Management.

Step 3 – Apply Custom Template (CRMNEW.wsp) to this new website I created.

  • Visit to URL from your machine, from machine which is not Central Admin machine but a domain machine. Visit URL, https://share.Company.com/sampleweb. In my example, I am visiting to http://mydevurl/sampleweb.


  • Option Solution Gallery, click Solution Gallery hyperlink. After click, notice the URL, it will take you to http://mydevurl/sampleweb/_catalogs/solutions.

  • Click Library tab and then click Solutions tab again from the office ribbon. It should look like:

  • Click Upload Solution option from Office Ribbon.


  • Click OK. After Ok, you need to activate the template you selected.

  • Click Activate from the previous window. As soon as you hit Activate, SharePoint will activate this Custom Template in new site collection you created.

  • Now Click Sample Web site URL.

  • It will take you back to Template Selection page.
  • Click Custom Tab available for option Template Selection. There you should able to see your custom template you uploaded in the /sampleweb solutions gallery.

  • Click Ok button. Now SharePoint is applying this CRMNEW template to the site /sampleweb you created. It may take couple of minutes to apply the changes. Once applied, next you have to create Permission groups.

Step 4 – DO NOT Create Permission Groups for the new site

Once /CRMNEW Custom template applied, the next option appear is to define the Permission Groups for the new site:


  • You do not need to define the security groups, because security groups have already been created. So simply click ‘Sample Web’ URL from top left. It will take you to the home page.
  • Your new site has been created.


Step 5 – Fix Broken Images (Top Right Corner).

  • Click Page Tab from the office ribbon section. And then click Edit button.

  • Now Click to select the broken picture on the right.
  • Then click ‘Delete’ button from the keyboard to delete it.
  • Now you have to add picture in the area, assuming that you have client image available locally. Follow these steps:

  • Click Insert tab from Office Ribbon, and then click Picture Button available inside it.


  • Click Save, it will browse to page as:

  • Click Page Tab from office ribbon, and then click Save & Close to apply the changes.
  • New web site has been created.

Step 6 – Apply Company Logo on top left corner.

  • Assuming you have Company Logo saved locally, Click Pictures option available on the left navigation under Pictures section.

  • Upload Company Logo here in Pictures List.

  • Click Open, and define other properties in the following screen appropriately.

  • Click Save button.
  • Now Company Logo has been uploaded and the URL to access to it would be http://mydevurl/sampleweb/pictures/Company_logo.png. IN production, it will be https://share.Company.com/sampleweb/pictures/Company_logo.png. Copy this URL.
  • Click Site Actions -> Site Settings from office Ribbon.

  • Under Look and Feel Section, click Title, description and icon.
  • Modify settings and paste the copied URL in URL text box.

  • Click OK to apply the changes.

You are all set.

Additionally, now you need to add users into appropriate permission groups etc.


Posted in Uncategorized | Leave a comment

Check-in document enabled during upload even though version-ing disabled

Network person reported that even though version-ing is disabled for a website’s document library, Check-in document is required while uploading a document. This became nuisance for some project team members.

I checked Document library settings and then General Settings -> Versioning Settings. It was all disabled, but still the problem persist.

Document Library - Versioning Settings

Document Library – Versioning Settings

I noticed that Check-in required option appears when ‘Title’ type is defined mandatory in the document content type. So I made it optional. As soon as I made it optional in the ‘Document Content Type’, Viola! Problem Resolved.

Here are the steps:
1. Go to Document Library Settings -> General Settings – Advanced Settings
2. Content Types – Click Yes to Allow management of content types.
3. Click Ok, and page will navigate back to Document Library Settings.
4. Because of Step2, now a section “Content Types” appear just after List Information.
5. Click to ‘Document’ Content Type.
6. Notice ‘Title’ column under ‘Columns’ Section. And Notice Status is ‘Required’. Click ‘Title’ hyperlink, and in the ‘Change Content Type Column’ page, change ‘Column Settings’. This column is [Change to] Optional [instead of Required]. And Click Ok.
7. Go back to ‘Document Library Settings’, then ‘Advance Settings’ and then click ‘No’ to ‘Allow management of content types.’ under section ‘Content Types’. Click Ok.

Posted in Document Check-in | Tagged , , | Leave a comment