Tuesday 7 November 2017

ADAL .NET v3: Authenticate without popping up a login form

After successfully working with OrganizationService endpoint for CRM, performing the CRUD operations I decided to move to WEB API because it is the future.

During my learning process, I had issues

  1.  I wanted the silent login: a situation where I provide the user credentials directly in the code. The sample code on MSDN didn't provide that scenario. It always popped up the login form.
ADAL v2 had a UserCredential Class that takes 0 or 2 arguments (username, password), which allows us to pass the credentials without a pop-up login form.

ADAL v3 UserCredential Class now takes 0 or 1 argument(username) which makes the scenario a bit different. In case you are using ADAL v3, the UserPasswordCredential Class should be used: It takes the username and password.

ADAL v2

 var authContext = new AuthenticationContext(Authority);
 var userCredential = new UserCredential(username, password);
 string accesstoken = authContext.AcquireToken(ResourceUrl, ClientId, userCredential);
Instead use
ADAL v3
  var authContext = new AuthenticationContext(Authority);
 var userCredential = new UserPasswordCredential(username, password);
 string accesstoken = authContext.AcquireTokenAsync(ResourceUrl, ClientId, userCredential).Result;

Sunday 29 October 2017

Retrieve values from GridView on SelectedIndex_changed

This is very different from rowindex_changed

For C#

Find the control, probably a label, of the data you want to retrieve.

    //Accessing BoundField Column
    string name = GridView1.SelectedRow.Cells[0].Text;
 
    //Accessing TemplateField Column controls
    string country =       (GridView1.SelectedRow.FindControl("lblCountry"as Label).Text;
 
    lblValues.Text = "<b>Name:</b> " + name + " <b>Country:</b> " + country;

An error occurred during local report processing in RDLC

I had this issue during the week and I have decided to put this as an article in my personal knowledge bank.

I tried to convert RDLC to PDF: it worked on my local machine but on getting to Azure I got this error: "An error occurred during local report processing in RDLC".

I didn’t  achieve this on Azure but I was able to resolve the issue using these instructions
  1. Add Microsoft Report Viewer dll to your solution( ReportViewer.common, ReportViewer.webform and ReportViewer.project object model)
  2. The dll must be of the same version.
  3. Set the “copy to local” property to true for all DLLs. (this is done so that the DLLs will be published with the solution).
  4. Install Microsoft Report Viewer Runtime same or higher version.
  5. Set the “BuildAction” property to content and make sure the name of the Report is the same as the name of the Report you want to use
  6. Set the “Copy to Output Director” property to “copy always” or “copy if newer”

Build and publish your project, the Report appears in the bin folder. I used another Host for the project and all was fine.


Wednesday 22 February 2017

CRM 2016 and SQL Issues

I woke this morning feeling good and it became awesome when I was told to install CRM 2016 on my company's server. As usual, I pulled my favorite web-link from my browser as a guide. All went well until little issues popped and it dawned on me I would spend much time than expected.


 The list of issues in a jiffy.

 I faced SQL related issues

Issue 1: I mistakenly "deleted my administrator's account in SQL Server 2012"
I thought of re-installing SQL, the process of copying my MDF and log files was going to be tedious for me. But I didn't do all that. I found this:
How I Resolved: SQL server itself provides a disaster recovery option. Members of Windows Administrator group now have access to SQL server when SQL server is started in a single-user mode known as maintenance mode.

I had to start SQL server in a single user mode through the SQL Server Configuration Manager tool

  1. Open SQL Server Configuration Manager tool, 
  2. Stop the SQL Server service, Right-click to select properties, 
  3. On the startup parameters tab add "-m" without the quotes click on add, apply and restart the SQL service Service.

With that, I was able to login to SSMS to create an Admin account in the security

Issue 2: Upon installation of CRM 2016, "My reporting service wasn't connecting to the database", it took a while to figure out I had to open Reporting Services Configuration Manager to adjust my servername and instance.

The third on the list "the instance name must be the same as computer name"
I knew I changed my computer name after I installed SQL Server 2012, but didn't expect an error during installation of CRM.
Name of Instance
before: WIN-IT8745;  after :SOFTCUB

How I Resolved it: I ran this code
SELECT @SERVERNAME AS [Server Name] to know my server name.

sp_dropserver 'WIN-IT8745'
sp_addserver 'SOFTCUB', local

Then I restarted my SQL Server Service and that resolved the issue.

Issue 4: I tried installing CRM again and I got this error " The Full-text component is not installed on SQL Server, Word Breaker Not Installed".
How I Resolved it:
This is a feature missing during my initial SQL Server installation.

  1. Run SQL server setup
  2. Choose the feature "Full-text component" and that resolved it.
  3.  Don't forget to restart your SQL Service so to remove any warning like "Word breaker is not installed"


Issue 5: The  SQL Server Reporting service is a local account and it is not supported."
Reason: The SQL server reporting service was installed using default settings,  and SrsDataConnector won't install while SSRS is running under default settings account.
How I Resolved it:

  1. Open Reporting Services Config Manager
  2. Update the Service Account to something like "local system"
  3. Click apply and complete the wizard by specifying the Location, password for the Encryption Key.



Tuesday 24 January 2017

Deploy 365 for Operations through LCS

Overview of the Basic Steps 
To setup AX7 or Microsoft Dynamics 365 for Operations. 
Prerequisites
  • Azure Subscription 
    • Two virtual machines of  D13, don't worry about setting this VM, it will be done automatically during setup. 
  • Microsoft Office Account
  • Browser mode must be InPrivate Browsing mode for Microsoft Edge browser or Incognito window for chrome browser
  • If you want to use your normal browser mode, delete its cookies and restart your browser.
With all these set, you can 

Start a new project in LCS
To use Lifecycle service to manage your environment you must create a project
  1. Goto https://lcs.dynamics.com.logon/index
  2. click sign-in
  3. Login with your Microsoft office 365 account
  4. Click + icon to create a new project
      5. Select project type

       6. Enter project information and click create

Creating a project was easy. Now let's Deploy environment

Before you deploy your environment you must setup VSTS,(Visual Studio Team Services).
VSTS Setup
  • Login to https://www.visualstudio.com
  • Click "Free Visual Studio" in top right corner
  • Under the Visual Studio Team Services, click "Free Account"
  • The user who wants to be VSTS owner should sign in with his/her work account.
  • Enter a customer/organization specific URL
  • Choose Team Foundation Version Control (TFVC) and click continue.
  • The VSTS account is created https://<org/customer>.visualstudio.com. This comes with a default project "My FirstProject".

In order to connect VSTS to LCS you will create another project.
  • Click on "Team Services" in the top left corner to exit the project
  • Click New under "Project and Teams"
  • Enter Project Name, Process Template must be Agile, Version control must be TFVC
  • Click "Create Project"

Finally for this section you need a Personal Access Token
  • Click on your name in the top right corner
  • Select security
  • Click on  Personal Access Token
  • Click Add
  • Enter a description
  • Expiration date: choose the maximum
  • Under Authorized Scope: Select All scopes
  • Create token.

This generates an alpha-numeric token which should be copied and saved because it is important for the connection to LCS.

Setup LCS integration with VSTS
  • Goto LCS: Setup VSTS is either found on the LCS homepage or in Project Settings


  • Enter VSTS Url
  • Paste Personal Access Token


  • Click Continue
  • Select the new  VSTS Project you created.


  • Click Save
  • Click Authorize


  • Click Yes


  • Click Accept

  • Setup is Complete


With VSTS Setup let's move on to the next phase. The Final Saga

Integrate LCS with Azure
NB: The steps in this section require the old and new Azure portal.
  • Goto Project Settings.
  • Click on Azure Connector on the left navigation pane.
  • Follow the steps here to Integrate LCS with Azure successfully.
After a successful integration, you should have something like this 



Deploy Environment
Environment should be deployed to an existing Azure subscription.
You can create an environment in two ways:
  • Deploy to Microsoft cloud (Azure)
  • Download the local VHD and operate it on-premise.

My thought on that if you ask, just go with the cloud. it takes more than enough resources to operate AX7 on-premise and also since 365 for operations is a cloud platform why drag yourself backwards.

  • Click on cloud hosted environment
  • In the Environment Click the +Add icon
  • Select your environment


  • Select the topology to deploy
  • Deploy your environment: Environment must not have space or number


  • Click the environment to view details about the deployment status.
  • The first deployment will take a few hours, but each subsequent deployment will be much faster.
  • When the deployment status changes to Deployed, click Login to connect to the client, or click the VM name to the development machine by using Remote Desktop.
  • After the deployment is completed, you can find the base URL, and also the information that you require to connect to the environment via Remote Desktop

Monday 23 January 2017

Microsoft Dynamics 365 for Operations Basic Setup

System Administration in AX7

Objectives 
  • Basic Data Setup and Configuration
  • Configure User and Security
  • Data Import and Export in AX

Basic Data Setup

Global Address Book is a central repository that contains information about each party that an organization has contact with.
Number Series: is a number sequence that defines the number available for use and the formatting of these numbers
  • Transactional Numbering: gives each transaction a unique number e.g. General Ledger, Purchase Order number, Invoice numbering.
  • Master Data Numbering: gives each master data a unique number e.g customer, vendor, workers.
  • System-wide Numbering: Basic numbering for basic processes and it is not module specific e.g. Activity, Case Number.

Legal Entity: is an organization that is identified through a registration with the legal authority
A company in AX is used to collect transactions related to one legal entity.
Multi-company Setup:
  • Currencies & Exchange rate: it facilitates upkeep of daily exchange rate
  • Fiscal Calendar: represents financial reporting periods.
  • Financial Dimensions: analyze financial data in more detail
  • Products determine the product setup of the company.

License Configuration and Parameters
License keys are used to control general access t functionality in the system.
Parameter forms each module control the specific function of each feature.
Configuration can be used to enable or disable smaller pieces functionality of the organization 

User
Users are connected to the Active Directory in order to work in AX.
Security Role gives access to functionality based on an employee's role in the organization.
A worker is linked to the user record through a user relationship record. This links users to Employees and allows functionality like commission and access to Enterprise Portal (EP).
User Profile: This linked to the user record to a Role Center which will be displayed as the homepage when logging into the rich client r Enterprise Portal

NOTE: Once a record is created in the worker section, it is automatically created in the Global Address Book.


Data Import & Export Tools
  • Data Import & Export Framework
  • Data Packages: these are XML files and transactional data uploaded into LCS and the data is deployed into AX
  • Excel Data connector.