Friday 13 July 2018

Create a batch job

Today I will be discussing about how to create a batch job.  Below are the steps which are required to create a batch job.

1. Go to system administration module -> Inquiries -> Batch jobs -> batch jobs











2. It will open a screen of batch jobs. Click on File and select new. A record for batch job will be added. Now add job description and select view tasks.
3. Now add new task by clicking on file then on new button. It will create a new task and you have to set its class name and company account.















4. For class click on text box and it will open list of class.
Note : Your class should extend RunBaseBatch. Then it will be visible in below screen shot.
















5. Now set batch group and run location. I have selected server as run location and batch group empty.




6. Now close task screen and you will be back on batch job main screen. Here you can set recurrence of batch job. For this you will select recurrence and add parameters according your requirements.






















7. Now you will be observing that you job is in withhold status. In order to start its execution. Change its status to waiting by clicking on functions drop down. Select change status then waiting option.


















Keep checking your job by refreshing it. Its status will be change from waiting to executing and then to ended.  There are chances you job might encounter errors. You can check them by clicking on log button available in action pane.

Create batch job using x++

Today I will be discussing about how to create batch job through x++.  Before going in code lets discuss what are batch jobs.

Batch job : It is group of tasks that submitted to an AOS for automatic processing. These tasks can run sequentially or simultaneously. Additionally, we can create dependencies between one task and another which means that we can setup a different sequence of tasks, depending on whether an earlier task successfully processed or fails.

You can create batch jobs either manually or by code. But here I will be showing a code snippet for batch job creation through x++. I have created a job just for demonstration which will create batch jobs. .













Note:  TestDemo class is my custom class that extends runBaseBatch. It will have its own run method which will contain business logic.
.
public class TestDemo extends RunBaseBatch
{}

Batch job Id :  It will be recid of current batch job.
SysRecurrence : This sysRecurrence class will be used to set recurrence of job. You may set it to default recurrence or as per your requirements
SysRecurrenceUnit : This method will be used to set count for retry. It need parameters and i have choosen 1 minute for retry.
Batchinfo : It will give batch information.
AddTask   : It will create /add task in batch job.Two parameters are required in this method one is  yourclassname and another is batchjobid.
parmCaption : It will be used for setting caption of job.

Tip : You can use this code for creating a single batch job with single task and as well as multiple task. It depend upon your requirements whether you want multiple task in parallel for instance dependency task.

For dependency task use this method : batcheader.addDependency(batchtask2, batchtask1, batchDependencyStatus::FinishedOrError);




Import and export label file in AX2012

Today I will be discussing about how to import and export label file in AX 2012.

Export label file 

Below are the steps required to export label file.
1. Open Dynamics AX. Go to AOT (Ctrl+D). Now expand label files node - select your label file - select language.
Note : I am exporting en_us language here.




















2. Right click on it. Select export file option. It will require path on which you want to place file.


















Import label file
Below are the steps required to import  label file.
1. Open Dynamics AX. Go to AOT (Ctrl+D). Now go on label file node and right click. Select create   from file option.













2. Select file from given path and it should be in ald extension. After selecting file a prompt will appear to replace or override file if it already exists.
Note: File will in ALD as show in below screen shot.

Tuesday 10 July 2018

Cannot override method on list page form

Today, I will be discussing about the reason for which we cannot override method on list page form.
Lets take the example of RetailStatementListPage. On this form if any one want to override delete command button click method but it won't be possible. As in below given screen shot the override method option is not available.

 






















Reason : In AX 2012 list pages can be directly deployed to Enterprise portal (EP). So, overriding controls of method is not allowed because they may be used in Enterprise portal.

If you really want to override the method then you need to change displayTarget property of the button to client and after this action you will be able to override it.
Please note that in this case you won't be able to use that method on EP. So, first be sure about your requirements.

Expired certification issue on development machines

Today, i will be discussing about one of the common issue of expired certification on development machine. You guys must have observed one of the common error while accessing AX through web browser typically using this URL (https://usnconeboxax1aos.cloud.onebox.dynamics.com/).
Error :  'There is a problem with server ' Sorry the server encountered a error. It is either not available or it cannot respond at this time. Please contact your system administrator. 






There might be different reasons for this error for instance: IIS services is not running or AX certification has been expired.
For better verification we will check first event log. It will  give us more details of this error. 
See in below screen shot the event log is giving ExpiredCertificateException.













Further on we can check our certificates by going on this navigation : Search Certificates -> Local Computers ->Personal -> Certificate 
Here you will find 4 expired certificates by checking there dates in expire column. 








Solution :  Replicate the certificates and update all references of expired one with new.
Following are the steps to go through this process.

1. Find certificates by going on following navigation : Search in Windows Start Menu : Certificates -> Local Computers ->Personal -> Certificate. They all will be expired.
  • DeploymentsOnebox.DaxRunnerTokenUserCertificate.pfx
  • DeploymentsOnebox.LcsClientCertificate.pfx
  • DeploymentsOnebox.MRClientCertificate.pfx
  • DeploymentsOnebox.SessionAuthenticationCertificate.pfx
2. Identify thumbprint of each certificate. By double clicking on them. It will open a screen, from there select Details tab. Search thumbprint there and you will get key from there. 
Note : Here I have opened DeploymentsOnebox.SessionAuthenticationCertificate.pfx. I will show the steps for one certificate rest of all certificates can be replicated  by following same steps.
3. Copy the key from there. In my case key is ‎f7 9c 64 b7 cd 90 91 13 28 81 8a 2b 10 df 8b da 27 36 cc 8e.
























4. Clone the certificate by opening the power shell as administrator and execute below mentioned  command. In my case i have used my own key shown in above screen shot where as 999 is duration of months after which certificate will be expired. You may set your own key and duration as per your requirements.

Command : 
Set-Location -Path "cert:\LocalMachine\My"
$OldCert = (Get-ChildItem -Path F79C64B7CD90911328818A2B10DF8BDA2736CC8E)
New-SelfSignedCertificate -CloneCert $OldCert -NotAfter (Get-Date).AddMonths(999)

Execute the command and you will see new certificate will be created. Copy the new key from power shell since you have to replace it on different places with old one in order to update reference.

5. Now update the newly created key in all referred files. For this process we need to update three files located in C:/AOSService/webroot/
  • wif.services.config
  • web.config
  • wif.config






Note : Open all these files in Notepad++ as administrator and replace old key with new one by using find and replace options. In last save the file.

6. Repeat same for all other three certificates.
7. Reboot the machine because it will restart all services. After reboot you will be able to access AX on web browser.

Friday 6 July 2018

Number of dimension values specified is different from the number setup in the active format for data entities

Lets discuss about the one of the issue (Number of dimension values specified in application development is different  from the number setup in the active format for data entities ) which anyone might face while import or export operations using entities.
Lets assume there is one of the common scenario in which you are uploading records for customer groups  along with its  financial dimensions using data entities.












Problem : Number of dimension values specified in application development is different  from the number setup in the active format for data entities.

Root cause :  There is difference in number setup of  excel file and active format of data entities.

Solution : Check your active format for financial dimension on following navigation (General ledger - Charts of accounts - Dimensions - Financial dimension configuration for integrating applications) and update excel file according to format or change its format. Then try to import data by using entity.

Below is the file format for customer groups uploading process through entities. For dimension value we are using  format Dimension1-Dimension2-Dimension3.


Import and export project in D365

Today, lets discuss about the process of importing and exporting projects in D365.

Export Project

Following steps are required for exporting project in D365.

1. Open visual studio as administrator.
2. Open the project to whom you want to export.
3. Right click on project and select export project option. It will open a screen where you have to give name to your project and axpp file will be generated.














Import Project

Following steps are required for importing project in D365.

1.  Open visual studio as administrator.
2. Go to Dynamics 365 -> Import Project . Or you may open the import screen by pressing Ctrl+R and Ctrl + P keys.




















3. Now select the file from your required path.
Note : Project file will be in axpp extension.

You will be having three options to open project.

  • Current solution : Open project in current solution
  • New solution : Open project in new solution
  • None : It will just overwrite artifacts and solution won't be saved.


















4. After selecting file from path. The hierarchy of artifacts will be shown in this way. You may select limited or all artifacts for overriding.

DB Sync fails - InvalidOperationException : Computed column returns empty value

Lets discuss about one of the common issue which might be the root cause of db synchronization failure. There is a scenario in which we have create a computed column that returns a value and you are using this statement for it "returns itemName".









Problem : In above screen shot there is a computed method which returns item Name. Since it is returning direct value by assigning it to a variable and there are chance that item name might be empty.
Note : It just a example, you have to map things as per your requirements for computed columns. As you know that computed columns are always used to  add computed values to a view and these columns do support sorting and filtering.

Problem : DB Sync fails - InvalidOperationException : Computed column returns empty value.

Root cause : Method is returning direct value for instance "returns itemName".

Solution : Instead of returning direct field, we need to replace the return statement with " returns SysComputerColumn class method for instance : SysComputedColumn::returnLiteral(variable name)"

Microsoft Windows Azure Storage Exception while exporting data from Local Machine

Today lets discuss about one of the common issue which might be encountered while exporting data through entities from local machine.










Problem : Microsoft Windows Azure Storage Exception while exporting data from Local Machine

Root cause : Microsoft Azure storage emulator is not running.

Solution :  Search azure storage emulator on start up and execute it.

Or Another option is to start it by using cmd. Following are steps to start azure storage emulator.

  • On OneBox VM, run command prompt as administrator
  • Navigate to  “C:\Program Files (x86)\Microsoft SDKs\Azure\Storage Emulator\”
  • Run “AzureStorageEmulator.exe start”


Thursday 5 July 2018

Accelerate data import process by using entity execution parameters

Lets discuss about execution parameters which are found in the Data import/export framework parameters. They can be used for speeding up data import process in order to optimize the performance when large number of records are uploaded using data management features.

As we all know that in Dynamics AX 2012 we used to define number of tasks at a creation of processing group. While here in D365 they are moved to Data import/export framework parameters.
Basically it is an option which provides information of dividing workload whenever we are performing records upload in bulk by using batch framework.
Lets begin with a scenario of  uploading sales order lines  in bulk. So, here we need to divide this upload process into sub tasks for better performance. For this purpose we need to follow some steps.

1. Open entity execution parameters by navigating on this path : Work spaces -> Data Management -> Framework parameters tile -> Entity settings -> Configure entity execution parameters









2. After clicking configure entity execution parameter, a screen will appear where we can add our entity.

  • Entity : Entity name will be selected from drop down and it will be used here for further process.
  • Import threshold record count : Here we can specify a threshold per entity when the tasks need to split and how many task will be created. For instance in below example 500 records will be processed per task. 
  • Import task count :  It will create multiple threads where the workload will be divided and run in parallel. For instance in below example 20 threads will be created.









3. Now its time to import the records in batch. For this navigate to Work spaces -> Data management -> Import tile 
Add all required details here for upload process and go on Import options -> Import in batch.
You process will be started and it will upload records in batch, You can monitor how many tasks are created on the View tasks form at a time of  execution of batch job. 













Note : It is not necessary that all entities will be supported for multiple task. See below screen shot like vendors entity is not supported for more than one task.


Wednesday 4 July 2018

Register for AzureApp ID

Today I will be discussing about how to register for Azure App Id. The purpose of creating Azure app ID is that whenever any application who wants to use the functionalities of Azure Active Directory (AD) so they must be registered in Azure AD tenant.
The registration process  includes giving of Azure Active Directory details of your application for instance URL where its located, the URL will send replies after a user authenticated, it will identifies the app and so on.

Following steps are required for registration of Azure App Id.
1. Sign in on https://portal.azure.com/.
2. It will redirect you to login page and if your account gives you access to more than one, click your account in the top right corner, and set your portal session to the desired Azure Active Directory Tenant.
3. On left hand side of navigation pane you will see a Azure Active Directory option and click on it.

















4. Now click on New application registration.













5. It will open a create page where you need to add name, application type and URL.

  • Name: Enter a meaningful application name
  • Application type:
    • Select "Native" for client applications that are installed locally on a device. This setting is used for OAuth public native clients.
    • Select "Web app / API" for client applications and resource/API applications that are installed on a secure server. This setting is used for OAuth confidential web clients and public user-agent-based clients. The same application can also expose both a client and resource/API.
  • Sign-On URL: For "Web app / API" applications, provide the base URL of your app. For example, http://localhost:89 might be the URL for a web app running on your local machine. Users would use this URL to sign in to a web client application.
  • Redirect URI: For "Native" applications, provide the URI used by Azure AD to return token responses. Enter a value specific to your application.

























6. After selecting create button, your app id will appear on screen. In my case its DemoApp along with its application ID.












7. Now Click on demo app and click on settings button. From there select required permissions option.

Note : You might need to use Owners option to make someone owner. Otherwise you may skip it.
















8. Now you have seen that Windows azure active directory permissions are already given to it.














9. For more permissions. Click on add button and select an API option.












10. Now select Microsoft Dynamics ERP and tick mark all permissions from select permission tab.
















11. Now click on add button and all permissions will be granted to it.















12. Now add permissions for Dynamics 365 for that again click on add button and search it if you don't find in list.


13. Grant permission to it by marking all check boxes from select permissions tab.
















14. Following permissions are granted to your DemoApp id.













Keys : In case of WebAPI you will require a secret key which will help in getting  client authentication.
Note: You need to give description to key and select its expires option. Also, remember key will be generated once so please save it as it won't be visible in future.   



How to apply hotfix

Today I will be discussing about to apply hotfix in D365. There are couple of simple steps to follow on.

1. Open visual studio as administrator.
2. Click on Dynamics 365 then on add-in and select apply hotfix option.



















3. Now select the hotfix file by using browse option.

















4. After successful installation you will be able to verify them by clicking on view Installed hotfixes tab.


Exposing data entities for OData

Today I will be discussing about to how to expose data entities for OData. First lets talk about what is Odata?

It is a standard protocol for creating and consuming data. Its main purpose is to provide a protocol that is based on Representational State Transfer (REST) for create, read, update and delete (CRUD) operations. It applies web technologies such as HTTP and JSON to provide access to information from various programs.
It provides following benefits.

  • Let developers interact with data by using RESTFUL web services.
  • Provides a simple and uniform way to share data in a discover able manner.
  • Enables broad integration across products.
  • Enables integration by using the HTTP protocol stack.
Lets say we have a scenerio in which we are integrating ax with another party for purhcase orders. All PO's will be created in their system and we need to have them in AX. For this purpose we will be creating a data entity which will be exposed publicly for Odata.

1. Open Visual studio as a administrator.
2. I have created DemoModel for it. Below is its screen shot and remember it is new package referring to basic models like ApplicationSuite, Application Foundation etc.

  
















3. Create a new project first. By clicking on File -> New -> Project -> Select unified operations from Dynamics 365 node.















4. Create a data entity by right clicking on your project. Add new item -> Data model -> Data entity















5. Select PurchTable in Primary Datasource option.
Note : Public collection name will be publicly used for exposing and i have selected limited number of fields from purchtable. You may select it as per your requirements.




















6. New entity has been created along will additional required artifacts 
























7. Note all properties and remember to change data entities name label as per your requirements. Because there are chances you might encounter issues while building project since data entity name might be be used by existing entities. .











8. Build and sync project.
9. For verification you may use this URL on IE and it will generate  json file. 




Final result






Note : Below mentioned URL will be used for checking any exposed data entity.  Just you need to add your data entity public collection name.
https://usnconeboxax1aos.cloud.onebox.dynamics.com/data/Data entity public collection name

Custom Business events Part 3 - (Activate custom business event) in D365 F&O

 In this blog we will discuss about the steps to activate a custom business in D365 F&O. As we know that business event catalog does not...