Using MS Word Templates with MS Dynamics 365

In today’s digital landscape, efficiency is paramount in business operations. Microsoft Dynamics 365, an integrated suite of business applications, offers robust tools for streamlining various processes, including document management.

Word templates within Microsoft Dynamics 365 are invaluable assets, allowing users to expedite document creation while maintaining brand consistency and professionalism.

Crafting Word Templates in Microsoft Dynamics 365:

  1. Select the Relevant Entity: Navigate to the appropriate entity within Dynamics 365, such as Leads, Accounts, or Opportunities.
  2. Access the Command Bar: Locate the command bar on the entity page and choose “Word Templates” from the menu.
  3. Initiate Template Creation: Click “Create Word Template” to begin designing your template.
  4. Design Your Template: Utilize the Dynamics 365 template designer in Microsoft Word to add dynamic data fields using predefined merge tags, ensuring personalized content.
  5. Customize Formatting: Align fonts, colors, and styles with your brand guidelines for a cohesive look.
  6. Save Your Template: Save the template within Dynamics 365, specifying the entity it corresponds to for easy retrieval.

Utilizing Word Templates in Microsoft Dynamics 365:

  1. Access the Desired Record: Navigate to the specific record within Dynamics 365 for document generation.
  2. Select the Template: In the command bar, choose “Word Templates” and select the desired template from the list.
  3. Generate the Document: Click “Create Word Document” to generate the document based on the selected template.
  4. Review and Edit: Open the document in Microsoft Word to review and make any necessary edits.
  5. Save and Share: Save the finalized document and share it directly from Microsoft Word with relevant stakeholders.

How to Remove Shared CRM View from database

CRM View

Microsoft CRM is very dynamic platform, it is helping collaborate and interact with team members. One of the cool features on Microsoft CRM, you can built View and share it with other team members.. But what happen, if you as an end user want to see this view anymore and you don’t have control to remove it! on this post, we will show you how to remove the shared CRM view from database.

Because of the nature MS CRM dynamicity, there will be a challenge to figure out and delete the sharing metadata.

The good side of this, all metadata is stored in the MS CRM database, thus you can manage that by updating database. I would like to highlight here, this is not recommended by Microsoft and you can do it in case you ran out of options but there is no guarantee from Microsoft this is will be working for you as well. I personally tried couple of times and worked fine with me.

I’m strongly recommend to take backup of your database before applying this change, so you have a backup point in case something went wrong.

DECLARE @userId UNIQUEIDENTIFIER = 'User ID whom have the view shared'

update PrincipalObjectAccess
set AccessRightsMask = 0  --Remove sharing
where PrincipalObjectAccessId in(

  select  poa.PrincipalObjectAccessId
  from PrincipalObjectAccess      poa
     inner join FilteredSystemUser u 
        on u.systemuserid = poa.PrincipalId
     inner join UserQuery uq 
        on uq.UserQueryId = poa.ObjectId
  where 
        poa.ObjectTypeCode = 4230
     and u.systemuserid = @userId
     and uq.Name in( 
        'Target View Name to remove it'
        )

 )

How to Send an Email in C# using gmail

Send an Email

It is becoming common these days to send an email from your application to specific list of users. Usually this is to notify users or administrators of certain action happened. As example of this, Notify administrator if an error happened in certain module, or notifying manager to approve/decline a request.

Thankfully, sending emails from .net applications (desktop or web) is becoming easy task to accomplish. Here is a sample code that utilizing gmail smtp to send an email. You can use the same steps to send email from outlook.com or office365.com, you will need to change the configurations in emailSettingInfo object

public void SendEmail()
{
    string sender, recipient, ccList, bccList, smtpSenderPassword;
    //Prepare SMTP Setting
    var emailSettingInfo = new
    {
        SmtpSenderEmail = "<<Sending Email Address Goes here>>",
        SmtpSenderPassword = "<<Sending Email Password Goes here>>",
        SmtpClientHost = "smtp.gmail.com",
        SmtpPortNumber = 587,
        SmtpEnableSsl = true
    };

    //Get the Email body ready
    var emailInfo  = new {
        ToEmailAddress = "<<Your email goes here>>",
        Subject = "Send Email from C# Code",
        Body = "Hi, this is a test email",
        CcEmailAddress = "<<CC List>>",
        BccEmailAddress = "<<Bcc List>>",
    };

    sender = emailSettingInfo.SmtpSenderEmail;
    recipient = emailInfo.ToEmailAddress;
    smtpSenderPassword = emailSettingInfo.SmtpSenderPassword;

    //Intialise Parameters  
    SmtpClient client = new SmtpClient(emailSettingInfo.SmtpClientHost);
    client.Port = emailSettingInfo.SmtpPortNumber;
    client.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
    client.UseDefaultCredentials = false;
    System.Net.NetworkCredential credentials = new System.Net.NetworkCredential(sender, smtpSenderPassword);
    client.EnableSsl = emailSettingInfo.SmtpEnableSsl;
    client.Credentials = credentials;
    try
    {
        var mail = new System.Net.Mail.MailMessage(sender.Trim(), recipient.Trim());

        mail.Subject = emailInfo.Subject;
        mail.Body = emailInfo.Body;
        mail.IsBodyHtml = true;
        if (!string.IsNullOrEmpty(emailInfo.CcEmailAddress ))
        {
            ccList = emailInfo.CcEmailAddress;
            foreach (var email in ccList.Split(";".ToArray()))
            {
                mail.CC.Add(new MailAddress(email));
            }
        }

        if (!string.IsNullOrEmpty(emailInfo.BccEmailAddress ))
        {
            bccList = emailInfo.BccEmailAddress;
            foreach (var email in bccList.Split(";".ToArray()))
            {
                mail.Bcc.Add(new MailAddress(email));
            }
        }

        client.SendCompleted += (s, e) => {
            client.Dispose();
            mail.Dispose();
        };

        client.Send(mail);//send the email
                
    }
    catch (Exception ex)
    {
        //Do Erorr Handling logic
    }
}

Angular PDF Viewer Component

You may come over a requirement to view PDF within your Angular 5+ application. Building that from scratch might be a time and effort consuming task. Thanks to ng2-pdf-viewr component, it is providing the developers with a ready made component that you can import into your Angular project and start using it in very easy way.

In my case scenario, The PDF Viewer latest version (7.0.1) didn’t work and it was giving me compilation issues whenever I’m try to compile my application. So I had to use an older version in my Angular project (I used version 6.4.1). By using the 6.4.1 version, I overcome the compilation issue.

I order to use the ng2-pdf-viewer, it is basically consist of few steps:

  • Install the component to be part of your project
npm i ng2-pdf-viewer@6.4.1  --save
  • Compile your application to make sure new component will be compiled successfully
  • Add PDF Viewer module to your module class
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { AppComponent } from './app/app.component';

import { PdfViewerModule } from 'ng2-pdf-viewer';

@NgModule({
  imports: [BrowserModule, PdfViewerModule],
  declarations: [AppComponent],
  bootstrap: [AppComponent]
})

class AppModule {}

platformBrowserDynamic().bootstrapModule(AppModule);
  • Add PDF Viewer html tag to your html page and make sure the pdf URL is pointing to a valid pdf file.
import { Component } from '@angular/core';

@Component({
  selector: 'my-poc-app',
  template: `
  <pdf-viewer [src]="pdfSrc"  style="display: block;" ></pdf-viewer>
  `
})
export class MyPOCComponent {
  pdfSrc = "https://blog.smartdigitizers.com/wp-content/uploads/TestPDFFile.pdf";
}

References:

https://www.npmjs.com/package/ng2-pdf-viewer/v/6.4.1
https://www.npmjs.com/package/ng2-pdf-viewer

Top 5 Reasons Why CRM is Important for Businesses

CRM Dashboard
Sample MySpace365 Dashboard

Customer Relationship Management (CRM) systems are becoming more important to overcome the operation issues and getting satisfied customers. I’m listing below the top 5 reasons why I believe you need to have CRM system in place.

  • Client Management
    CRM system helps you to get more visibility into your client base, ponder the tactics needed for long-term profitability, and formulate better plans that impede your staff to break new operational ground.
  • Profitability Tracking
    They no longer need to worry about tracking every cent of revenue and focusing on shipping costs, product discounts, and client returns. Revenue calculations will be a matter of reporting issue on the CRM. Also tracking your client invoices and payments will be within the CRM system. It will also be providing notification tool for you to make sure you are collecting payments in timely manner.
  • Regulatory Compliance
    This is a winning approach in the long term, especially when it helps you comply with your country rules and industry standards. You can instruct the CRM to flag a high-risk client or generate the relevant documentation based on the client’s risk score.
  • Sales Strategy
    As a business owner, the last thing you want is to lose income by targeting the wrong customer segment. Client administration programs can provide you valuable intelligence about long-term sales trends, helping you adjust the existing corporate sales strategy and results tactics, which is ultimately will turn into more revenue coming in the pipeline.
  • High Customer Satisfaction Rate
    CRM can improve a company’s customer service practices, helping employees respond to clients’ queries quickly and effectively. The CRM enables your company to understand what it takes to build an effective customer outreach policy and boost sales. Before selecting a customer tracking program, make sure it fits your company’s operating processes, industry, revenue cycle, and customer base.

While keep in mind the best CRM practices, Smart Digitizers is offering a cloud-based CRM System; MySpace365. I encourage you to read more about it and reach out to them to get better understanding of how this can fit into your needs.

flutter doctor –android-licenses gives a java error

After installing flutter on my development environment, I face flutter doctor android license issue while I was checking the installation with below command:

flutter doctor --android-licenses
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
    at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
    at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
    at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
    at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
    at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
    at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:581)
    at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:178)
    at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
    ... 5 more

That was not the expected result as I follow the installation instructions step by step documented on flutter official site.

I could successfully fix the issue by simply install install Android SDK command line tool from the Android SDK Manager, in order to do that, follow the below steps

  1. Start Android Studio
  2. Go to Tools > click on SDK Manager
  3. From the left-hand side choose, Appearance & Behavior then System Settings then Android SDK
  4. from the tabs, Select SDK Tools 
  5. Check Android SDK Command-line tools 
  6. click ‘apply’.

Below screenshot is showing the settings popup (I have dark theme on Android Studio)

Android Studio – Settings popup

If you are still facing issues after applying above steps, consider upgrading JDK to the latest. here is the Java official upgrading JDK 8 (latest at this moment)

Microsoft announced the born of new baby; the Windows 365 Cloud PC

Recently Microsoft announced the born of Windows 365 to be early August 2021; It is the Cloud PC version of Windows OS that is dominant over the years. I believe this is will change the whole game in the hybrid working environment

COVID-19 pandemic enforce business to start thinking of the remote working as the best option to overcome the health issues.. Organizations everywhere have transformed themselves through virtual processes and remote collaboration. The ability to work whenever, however, and wherever it’s needed has become the new normal. Everyone want to have working environment that has technologies that’s familiar, easy to use and easy to access. Hybrid working environment becoming the key to success. Microsoft announcing Windows 365; the Cloud Windows version with almost the same experience as Windows 10 or Windows 11. This will be great empowering tool for businesses to move on the Hybrid working model.

Full Windows experience in all devices.. just like what we used to have.

With this great hybrid work paradox, leaving organizations around the world with multiple options to decide how to get connected in a hybrid world and provide the employees with the needed access to organization’s resources from anywhere. All what they need is to have internet connection.

From my point of view; I can tell that the Cloud PC (Windows 365) is a great technology feature that will change the game. Having a secure full version of windows 10/11 experience will enhance and empower the workspace, regardless of the workforce location or devise.

One of the great features is that you can stream all of your personal apps, tools, data and settings from the cloud across virtually all devises including iPad, Mac and android devises.

Familiar tools

I always say, Simplicity is the key to success. Windows 365 have that in hart of the design principles. Microsoft promise us that we can apply the management and security policies to the Cloud PCs in easy way. Also you can monitor the Cloud PC performance and processing power, and easily find the Cloud PC that is not working with best performance needed.

Zero Trust Powering the Cloud security

Per Microsoft, The Cloud PC architecture has been built while keeping in mind the best security practice; Zero Trust architecture, Windows 365 also helps solve for today’s critical security challenges by design, storing and securing information in the cloud, not on the cloud device itself.

Microsoft built Cloud PC specific Security baseline for quick start, you can alter these security policies later on to fit you needs but we wouldn’t recommend doing that without a solid understanding of the side effect turning off these features. Windows Defender is a built-in software into the Windows 365.

The Security baseline provided by Microsoft It not only protects your Cloud PCs, but also gives you security recommendations to lower risks, and helps you quickly find out and troubleshoot any security incidents.

Learn more information about Windows 365

References:
1. https://www.microsoft.com/en-us/microsoft-365/blog/2021/07/14/introducing-a-new-era-of-hybrid-personal-computing-the-windows-365-cloud-pc/

How to Implement Keyboard Shortcuts for your Web Application

In order to increase the user productivity and efficiency while using your web application, you might ended up implementing some sort of keyboard shortcuts. This will enable the end user to use the keyboard to do some actions or to navigate to certain pages without the need to use the mouse.

Implementing keyboard shortcuts in Angular is pretty simple thing. Basically you will need to decorate your Angular event handler method with HostListener attribute.. yes, that’s it. Here is a code sample that will show how to let the user using F10 to save the record

import { Component, HostListener } from '@angular/core';
export class AppComponent {
constructor() {
}

@HostListener('window:keydown.f10', ['$event'])
showPinned(event: KeyboardEvent) {
   event.preventDefault();
   alert('F10 pressed');
   this.save();
}
@HostListener('window:keydown.control.p', ['$event'])
pinRecord(event: KeyboardEvent) {
   event.preventDefault();
   alert('Ctrl+P pressed');
   this.saveRecordIntoHistory();
}
save() {
   //Implement Saving Logic here.
}
saveRecordIntoHistory () {
   //Implement Saving Record into History Logic here.
}
}

References

I built this article based on below references

  1. https://angular.io/api/core/HostListener 
  2. https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault 

How To backup MySQL DB on Windows severs

Backing up database is essential to eliminate the risk of losing data whenever there is a hardware failure or software issues. In this post, I’ll be showing the possible ways to create backups for MySQL databases.

In fact, There are several ways to Backup MySQL databases, you need to evaluate each one and select the best fit into your needs. I’ll list the possible ways, but I’ll be focusing on the data dump approach.

Types of MySQL backups:

  1. Logical: By using MySqldump utility, you will be able to create a data dump of your database. The Expected output is a .sql file that has all insert statement needed to re-create the database again.
  2. Physical: by coping the actual database files into another location. – This approach usually is recommended for huge databases as it is faster to do the backup and faster to restore in case of any failure. The limitation of this approach, is restoring the database has to be on the similar hardware as the original one.
  3. Partial: Partial backup is meant to have a backup of single table. This is usually useful when you wat to do a bulk operation on that table and you want to create a restore point in case of any failure happened.

For the purpose of this article, I’ll be focusing on the first option; Logical Backup. It is the easiest way as well as it is using a built in tool called mysqldump. This utility tool is being shipped with MySQL engine, Thus it will be installed by default on your MySQL Server. – So no third party tool needed.

You can create a .bat file to do the backup and get benefits of the built-in Windows Task Scheduler to have the backup done on daily basis. Let’s dive into it.

  • Creating backups for all databases on my MySQL engine:
mysqldump --user=root --password=******* --result-file="C:\MySQLdump.sql"  --all-databases

On this command line, you are telling mysqldump utility to have a backup of all databases and store it on the C:\MySqlDump.sql file. If you open the result file in any texts editor, you will find a normal sql statements to insert the data.

  • Creating Backup for a single database:
mysqldump --user=root --password=******* --result-file="C:\MySQLdump.sql"  --[DbName]

it is the same command as all databases, but you need to replace the all-databases option with the name of the database that you are looking for backing it up.

Advantages of using data dump approach over other options:

  1. You are not limited to specific MySQL version. The output of this dump, is normal SQL CRUD operations which means all what you need to do is to connect to the new MySQL engine and execute the datadump file.
  2. You can edit the datadump file in case you are looking to do few tweaks before executing it again.
  3. No 3rd party tools are needed. The MysqlDump.exe tool is built in utility and will be installed within MySQL installation.

For more information about mysqldump, please see the MySQL related documentation here

JQuery/JavaScript: how to split string based on Caps letter

In certain cases, you might got a need to change a string content in order to display it in more human readable format. recently I faced a need where I need to tokenize a string based on caps letter and add spaces between words

Using the built-in RegEx feature on Javascript, you can split the string and tokenize it based on the capital letters on the string. For example if you would like to split the string “TestStringValue” to be “Test String Value” you can simply use the following syntax:

/*split string based on Cap letter, then joins the resulted array elements with space between each array entry*/
split(/(?=[A-Z])/).join(" ") 

to try it, use the following code:

alert(  window.prompt("Tokenize String: ", "TestStringValue").split(/(?=[A-Z])/).join(" ")  )