Sunday, September 24, 2023

Publish your App on AppSource- Dynamics 365 | Power App

How to publish power apps on Microsoft Appsource from scratch?

Scenario: I have a Canvas app in a separate unmanaged solution. To prepare it for AppSource, I'll first download it as a managed solution and generate an AppSource package using Visual Studio. This process involves creating input.xml, content types XML files, and terms of use HTML files. Finally, we will zip all the files, including the app logo, and upload them to blob storage to get the URL which I'll then submit to the Microsoft website for app validation and publication. The entire process includes 5 stages of confirmation, and once it passes all of them, the app will be successfully published and available to clients/users on MS App source.
Once your package successfully clears all validations, it will be prepared to go live, and you should expect to see the following status in your Microsoft partner account.

Follow the video to see its implementation Part 1 and Part 2
  


Note- The steps mentioned in the Microsoft blog need to be revised. I followed the steps mentioned in the MS blog and submitted it for publishing, but it failed in the validation stage. I also made several other errors, which I will show you in this blog.

There are five validation stages for publishing an app. Our package has successfully passed the critical automated validation phase, and it received confirmation that it meets expectations.


However, even if you've followed all the steps correctly, the Microsoft team may reject your app publication if it uses deprecated APIs or codes that are not recommended. In our case, Microsoft advised us that we used certain components like DOM and parent relationships, which are discouraged during the app development. They recommended replacing these with the supported Client API object model.


Microsoft Support Form
This is a Microsoft support form where they may request details and provide assistance. You can access it here: Support Form
Errors - I've shared various errors below that I encountered from Microsoft teams during the package-sharing process for publication and the package creation and deployment.
Prerequisite - 

  • Visual Studio 2019
  • Power Platform tools in Visual Studio or 
  • Microsoft Power Platform CLI
  • Managed solution of your app

There are total 5 steps involved in this (explained in detail below)


Step 1: Create a Microsoft Partner Center account 

Step 2: Create a managed solution for your app 

Step 3: Create an AppSource package for your app 

  • Create connection
  • Create deployment package
  • Create input and ContentTypes files in XML
  • Add app logo (32x32 size in PNG/JPG format)
  • Zip all the above fields to create a Final package

Step 4: Store your package on Azure Storage

Upload the package in Azure blob and get the URL


Step 5: Submit your app on Partner Center

Share the detail and blob URL for validation and wait for it.


Let's see how to create a package structure with the step-by-step process. First, we'll create a Microsoft Partner Center account and download the managed solution through PowerApps. The third is creating an AppSource package in Visual Studio for the app. After this, we will make input type.xml and content types.xml and zip all files into a package. The fourth one is Azure Storage, which generates a URL with the SAS key. Lastly, we will upload the URL to the MS partner account for validation and publication of the app.

Step 1: Create a Microsoft Partner Center account

Firstly, we need to have a Microsoft Partner Center account. If you need to become a member of the Microsoft Partner Center, you must enroll at https://aka.ms/joinmarketplace. You must be a member of the Partner Center to publish apps on AppSource. 
Note - If you're using your company's email in your Microsoft Partner Center account, you must request MPN admin access to view settings and publish the app.
Below are general steps for creating an account, click on the Microsoft Partner Center account and provide the requested details in each Step. If you already have a Microsoft Partner Center account, skip the steps below and go straight to Step 2.

You'll receive the following message if you already have an account with the same email address.

You must request MPN admin access to view settings and publish the app.

Step 2: Create a managed solution for your app

First, let's see how to create a solution. Login to powerapps.com with your user ID and password.
Click on your solution and select "Export."

Ensure all customizations are published. Click on the Publish button for this.
Click "Next."

Choose "Managed" as recommended, and proceed to export.
Once the export is complete, download it and locate it in your downloads folder. Copy the file path and paste it into a notepad for future reference to execute in its CLI
My solution path-  "C:\Users\RajnishMahaseth\Downloads\AugustSolution_1_0_0_1_managed.zip" 
Now, we are moving to the third Step.  

Step 3: Create an AppSource package for your app

Create an AppSource package (.zip file) to include your solution and other required files. An AppSource package consists of the following files:

This Step focuses on creating a package project and outlines how to use the CLI and PowerPlatform. There are two methods for creating a package structure: one using Visual Studio Code and the other using Visual Studio 2019.
Visual Studio download link - here
Visual studio code  download link- here
In both cases, we'll be using the same commands. For simplicity, I'll choose Visual Studio 2019. First, let's explore Microsoft PowerPlatform CLI. There are two ways to use it: through Visual Studio Code and through PowerPlatform CLI for Windows using Command Prompt or PowerShell. Visual Studio Code is suitable for Mac OS, Windows 10, and Windows 11, while the second method is exclusive to Windows. If you're on a Mac, go with Visual Studio Code; if you're on Windows, you can choose either way. Now, let's dive into how to create a package using Visual Studio on a Windows machine.

We will require the environment URL where the solution is located.
Log in to Dynamics CRM →Click on "Settings."→ Navigate to the "Admin Center."

Go to environments from the left pane and open your environment.


Copy the Environment URL (e.g., https://org44ad4e8e.crm.dynamics.com/). You will need this when establishing a connection from either Visual Studio or the CLI.

Open Visual Studio, and click on continue without code.

We need to have Power Platform Tools to make the package and run commands for it. So go to Extension→Manage Extension→Find Power Platform tool and install it.


After the installation, the PowerShell terminal will be opened. We can start executing the commands for creating the package. (Since it is already installed,  it is not showing the install option. You can install it. Once it is installed,  click on the terminal. A new window will be opening. Just execute the below commands)

Create a new folder on your desktop (or any preferred location). This folder will be the storage location for all the necessary items to create the package.
My folder location is C:\Users\RajnishMahaseth\Desktop\DynamixPower
Let's open that path first in the terminal

Execute Command 1 - cd C:\Users\RajnishMahaseth\Desktop\DynamixPower


Now, let's establish a connection with Dynamics 365. We'll require the environment URL path we copied in the previous Step (e.g., https://org44ad4e8e.crm.dynamics.com/).
Command 2 - pac auth create --name RajnishMahaseth --URL https://org44ad4e8e.crm.dynamics.com/
You'll be prompted to log in. You can select the logged-in account if the Dynamics 365 environment belongs to the same account or choose "Use another Account."


Once the connection is established, you will see the message "Authenticated successfully."

Command 3 - pac package init --outputDirectory DeploymentPackage This will generate a folder named "DeploymentPackage" containing the deployment package. After executing this command, you'll receive the message "Package project created successfully."


 Next, we'll navigate inside this package. 
Command 4 - cd .\DeploymentPackage\


We are including the solution in this package. Here, you need to specify the path where the managed solution was downloaded in Step 2.
Command 4 - pac package add-solution --path "C:\Users\RajnishMahaseth\Downloads\AugustSolution_1_0_0_1_managed.zip"



The fifth command is "dotnet publish," which we will use to publish the package.
Note: if these four commands don't work after installing the .msi, please try to install the latest version of the .net.  After installing this latest version of the .net, you can execute all these four commands. One more thing is that if you have multiple solutions in your request, you can run the third command. How many solutions you have you can execute that many times.

Command 5 - dotnet publish



Open the folder where you're executing these commands, you should see a folder structure like this:
The deployment package is created successfully. Your package is comprised of the following files within the `<Project>\Bin\Debug` folder:
<PackageName> folder: The folder is named according to your package folder name, as changed in step 2.g of this section. You'll find all solutions, configuration data, flat files, and package contents in this folder.
You may also encounter a `.NET` folder (e.g., net472) containing a `pdpublish` folder. Your DLL and other project files are in this `pdpublish` folder.
<PackageName>.dll: This assembly holds the custom code for your package, and by default, it shares the same name as your project.

Optional Step (you can skip it; the package is already built, so it won't impact anything). This Step is for testing the app in another environment. After you create a package, you can deploy it on the Dataverse instance.
To deploy using the CLI, use the pac package deploy command.
Command 6 -pac package deploy --package .\bin\Debug\DeploymentPackage.1.0.0.pdpkg.zip
You may encounter an error here: "An error occurred for solution DynamixPower. You cannot replace an unmanaged version of this solution with a managed one."
Solution: It's not possible to have both a managed and an unmanaged solution with the same name and version in the same environment. To resolve this, attempt to deploy it in a different environment. Rerun command 2 with a different environment URL.

Be aware that you might encounter dependency issues in the new environment. Managed solutions often rely on other solutions or components within the target environment.

In summary, we've created a folder named "DeploymentPackage," added the solution to this package, and then published the package.
Let's open the folder and go to bin→debug and copy the "DeploymentPackage.1.0.0.pdpkg" zip file.


Now, let's create a folder. I am giving it a name as a Package. Paste that dpkg file over here.
Create an icon for your app source package. The size should be 32x32. Or download your company logo(size 32x32  and move it to this package location. Name it logo32x32. Valid file formats are PNG and JPG. Now let's create input and content types XML files

Creating [Content_Types].xml Open the folder(Package) we previously created. (Make content types and input files should be of only XML format and not be any other documents.) Right-click on mouse→New→Text Document. Now open that document in Notepad.


Go to this Microsoft page for copying code of [Content_Types].xml. Create an AppSource package for your app. Click on copy and paste code in Notepad.

[Content_Types].xml file that provides MIME type information of the file type extensions included in your package. This is separate from the one that will be included again in the AppSource package. The naming convention should be the same as in the document. We need to save it in XML format. Click on File→Save as

Give file name as [Content_Types].xml and save it
Note - If you have other extensions here, such as  CSV,  you can copy this command and paste it down. For example, here, msapp is there. You can add CSV. Once it is done,  click on save and close it. e.g. <Default Extension="csv" ContentType="application/octet-stream" />

Creating input.xml 
Go to this Microsoft page. Create an AppSource package for your app, and copy the input.xml. Navigate to the folder. The same document has been opened previously. Just open it. Paste it.


We need to make specific adjustments to the information in the input file to align it with our package details. Let's begin by editing the input.xml file.

  • Here, you will find the provider's name, which can be your company's name or any other designation you prefer.
     <ProviderName>PowerDynamix</ProviderName>
  • Next, focus on the package file, which originates from the CLI command. Simply copy this dpkg file and rename it if desired. When you rename it, paste the new name, along with the extension, into a notepad. Remember that extensions are mandatory.
     <PackageFile>DeploymentPackage.1.0.0.pdpkg.zip</PackageFile>
  • Now, let's address the solution anchor name. This name should differ from your managed solution's name. Since it's already in the notepad, copy and paste it along with the extension.
    <SolutionAnchorName>AugustSolution_1_0_0_1_managed.zip</SolutionAnchorName>
  • The start date should be formatted as MMDDYY and set to two days before the current date. Additionally, the end date can be any date, but it must be at least one month from today's date, and it should also follow the MMDDYY format. 
     <StartDate>20/09/2023</StartDate>
    <EndDate>01/01/2031</EndDate>
  • Moving on to supported countries, consult the document for the list of countries. Decide which regions you want to publish your app, then copy and paste these regions into the notepad. You can edit them as needed, but ensure no spaces or new lines between the country codes. For clarity, separate the country codes with commas and ensure that supported countries remain on the same line, including the ending tag.
    <SupportedCountries>US, CA,AD,AE,AF,AG</SupportedCountries>
  • Regarding the "Learn More" link, you can use your company's website link. 
    <LearnMoreLink>https://powerdynamixx.blogspot.com/</LearnMoreLink>
  • As for the package's local code, the default is 1033 for English. If you plan to publish your app in different regions, refer to the document for the appropriate local codes.
  • Additionally, ensure that the package's local code matches the solution.xml file. Open the solution.xml file located within the pdpkg folder. If multiple languages exist in the solution.xml file, ensure that the input.xml file contains the corresponding language codes. Both the solution.xml file's local codes and language codes should match those in the input.xml file.
  • Regarding the logo, follow the naming convention mentioned in the folder. If the logo is 32x32, use the same naming convention and extension in the input.xml file. 
    <Logo>logo32x32.png</Logo>
  • The same naming convention and extension should also be applied to the terms of use in the user.html file. (I will show how to create an HTML file in the next Step.)
    <PackageTerm File="TermsOfUse.html" />
In summary, ensure all aspects of the input.xml file adhere to these guidelines. Avoid errors when publishing the offer by ensuring correct extensions, the right package file name, distinct solution anchor names, and properly formatted start and end dates. Maintain a consistent format for supported countries, match language codes, and follow the naming conventions for logos and terms of use.
If you have any data files, incorporate them into the input config files by referencing the document and adding the necessary attributes.
Once details are modified, click save as and save the file name as Input.xml and save it.

Now, let's delete this text document from the package folder. The next is to create an HTML file for the license. It should be in .html. Your terms and conditions can be created by the HTML file.

Creating TermsOfUse.html Create an HTML file containing your license terms. If your app supports multiple languages, you can have an HTML file per language to display the license terms in the user-selected language. The HTML file is mandatory. Open Notepad or Notepad++. Create an HTML file containing your company's terms and conditions, then save it in HTML format.


The package is now fully prepared. Refer to the snapshot below; your Package folder should contain the following files.
Select all the files, then compress them directly. This will create the final package. Be sure to cut and paste it outside the folder for clarity. Once the final package is ready, let's proceed to copy just the fourth URL.

Step 4: Store your AppSource Package on Azure Storage & generate a URL with the SAS key

To maintain the security of your files, we need to store the AppSource package file in a Microsoft Azure Blob storage account and use a Shared Access Signature (SAS) key to share the package file. Your package file is retrieved from your Azure Storage location for certification and then for AppSource trials.
If you're using a company account, ensure you have access to the blob storage. If you don't have access, request it.

Here are the steps in the process:

  • Begin by logging into azure.microsoft.com and signing in to portal.azure.com.
  • Once signed in, navigate to the storage section and create a container from there.
  • For more comprehensive instructions on creating containers, refer to the provided documentation below.
  • Set the start date two days before, as specified in the input.xml, and ensure that the expiry time is set to at least one month.
  • After you've completed these steps, proceed to generate the SAS URL.
  • Copy the generated SAS URL and paste it into the partner center to upload the package.

Here are the steps from the Microsoft page: Store a package in Azure Storage

To upload your package to Azure Blob storage:

  1. Create a free trial or pay-as-you-go Azure account at https://azure.microsoft.com.

  2. Sign in to the Azure Management portal at https://portal.azure.com.

  3. Create a new Storage account by clicking > Storage > Storage account - blob, file, table, queue.

    Create a Storage account

  4. On the Create storage account page, specify the NameResource group, and Location for your storage account. Leave the rest of the columns with the default options. Click Create.

    Specifying account values

  5. After your storage account is created, navigate to the newly created resource group, and create a new Blob container. Under Blob Service, select Containers, and then + Container.

    Create a new Blob container.

  6. Specify a name for your container, and select the Public access level as Blob. Click OK.

    Set access level of the Blob.

  7. Start Azure Storage Explorer on your computer, and connect to your Azure Storage account by signing in using the same account with which you created your Azure Storage account.

  8. In Azure Storage Explorer, select the newly created container, and then select Upload > Upload Files to upload the app source package that you created in Step 4: Create an AppSource package for your app.

    Upload the app source package.

  9. Browse to the AppSource package file on your computer, and select to upload it.

  10. Right-click on the uploaded AppSource package file, and select Get Shared Access Signature.

    Selecting Shared Access Signature

  11. On the Shared Access Signature page, modify the Expiry time value to make the Shared Access Signature (SAS) active for a month from the Start time. Click Create.

    Set an expiration time

  12. The next page displays information about the generated SAS information. Copy the URL value and save it for later. You will need to specify this URL while creating an offer in the Partner Center.

    Copying the SAS URL


Submit your app on Partner Center

Once you have obtained the URL from blob storage, you can use the Partner Center (link here)to submit your app for listing on Microsoft AppSource. As previously mentioned in step 1, ensure you have MPN admin access to manage settings and publish the app.
Snap of a user having access

Snap of a user having no access

Once your package successfully clears all validations, it will be prepared to go live, and you should expect to see the following status in your Microsoft partner account.

Errors during the package sharing process for publication and the package creation.


Error 1- We found the below error in your package- unable to download the file from the Azure blob that you have provided at the partner's center.  URL of the package location is either no longer available or it is missing authentication tokens.

Solution- To resolve this issue, you should renew your blob URL and then update the new URL within the Partner Center. After making this adjustment, you can proceed to publish your package once again. When generating the SAS token, ensure you set the start date to the current date minus one day and the end date to the current date plus ten days. For more information and guidance, you can refer to the reference
link here

Error 2- This XML file does not appear to have any style information associated with it. The document is shown below. Authentication failed. The server fails to authenticate the request.

Solution- check how you are constructing the authorization header in your application. Ensure that it includes all the required components, such as the Shared Key Signature, and that it is correctly formatted.

Error 3 - Folder structure issue: The folder structure that you mentioned inside the BLOB package was incorrect. Please refer to the below guideline URL for proper package structure.

Solution- Ensure that all the necessary files and components of your app are in the correct locations within the package. This includes any metadata files, icons, images, configuration files, and the main application files.

Error 4 - Syntax Error in Input.xml file - two times zip.zip

Solution- Ensure that you include the extensions of all files in the input.xml file. Avoid duplication or omission when copying and pasting.

Error 5 - Syntax Error in Input.xml file - missing header for <LearnMoreLink>
Solution- Ensure to place the end header of all files in the input.xml file.

The next error you may encounter occurs only after successfully passing all automation validation stages. This error arises during manual validation checks and may be attributed to the use of certain components, such as DOM elements and parent relationships, which were employed during the app's development but are not recommended.

Error 6 - Code Issues in Canvas App:
Check for usage of DOM in the form
Check if the parent relationship is used

Solution- We need to review and update the code of our Canvas app and re-submit your package
Here are some recommended references by Microsoft to follow (with link):

Monday, August 28, 2023

Filter Lookup Records in Dynamics 365 | Power Platform

How to filter lookup records in Dynamics 365?

Scenario: Imagine you have a list of cases in an Opportunity form, and you click on a field called "Case." Right now, it shows all cases, including the ones that are no longer active. But I only want to see the cases that are still active, not the inactive ones. So, we'll set it up to only show the active cases. You can do the same with other filters if needed.

Follow the video below to see the implementation.




Filtering a lookup field in a Dynamics 365 form allows you to restrict the choices available in the lookup based on certain criteria. This can be particularly useful when you have a large dataset and want to help users find and select the right record quickly. You can use multiple filter criteria by clicking the "Add Condition" button in the "Add Custom Filter" dialog, allowing for more complex filtering conditions.

Prerequisites:
Before we begin, make sure you have the necessary permissions to customize forms in Dynamics 365. You should also have a basic understanding of how to navigate and use the Dynamics 365 platform.

Steps to Set Up a Filtering Condition for a Lookup Field to Display Only Active Cases:

1. Log in to Dynamics 365:
   Start by logging in to your Dynamics 365 account with the appropriate credentials.

2. Navigate to the Opportunity Entity:
   Go to the area where your opportunities are managed and locate the Opportunity entity.

3. Customize the Opportunity Form:
   - Click on "Settings" (represented by a gear icon) in the upper-right corner.
   - Select "Advanced Settings."
   - In the new window, choose "Customizations" and then "Customize the System."

4. Edit the Opportunity Form:
   - In the Solution Explorer, expand "Entities" and select "Opportunity."
   - Under "Forms," find and select the form you want to customize (typically "Main Form").
   - Click on "Form Properties" in the ribbon.

5. Add a Subgrid for Case:
   - In the form designer, locate where you want to add the list of cases.
   - Drag and drop a "Subgrid" control onto the form.

6. Configure the Subgrid:
   - After adding the Subgrid control, double-click it to configure its properties.
   - In the "General" tab, choose the "Cases" entity as the data source.

7. Set the Filter Criteria:
   - In the "Data" tab of the Subgrid properties, scroll down to "Add Predefined Filter" and click on it.
   - Define a filter criteria that displays only active cases. For example, you can set the "Status Reason" field to "Active."
   - Save and close the Subgrid properties.

8. Publish Customizations:
   After configuring the Subgrid, make sure to save and publish your customizations.

9. Test the Form:
   Go back to your Opportunity entity and open an opportunity record. You should now see a list of cases related to that opportunity, filtered to display only the active cases.

Conclusion:
Customizing Dynamics 365 forms to display specific information, like showing only active cases in an Opportunity form, can greatly enhance your organization's efficiency and user experience. By following the steps outlined in this blog post, you can easily set up a filter condition to meet this requirement and ensure that your team works with the most relevant data.

Thursday, August 24, 2023

Introduction to Dynamics 365 Solutions

In Dynamics 365, a solution is like a special package that helps you change and improve the software to match what you want. It's a bit like using different tools to customize a toy to your liking. Solutions make it simple to share these changes with others and keep everything organized. It's like a recipe to make Dynamics 365 work exactly how you need it to!

Embracing Extensibility

Imagine the canvas of Dynamics 365 stretching before you, ready to be painted with innovation. Solutions are your palette. You can extend the power of Dynamics 365 Customer Engagement using solutions, either by directly importing applications with native components or creating installers for those with external components.

Harmony in Versions

Navigating the journey between Dynamics 365 versions becomes a breeze with solutions. Migrating your solutions? No problem. The compatibility chart guides you, allowing solutions to gracefully journey through versions and service pack releases.

Components, the Building Blocks

Solutions are about crafting excellence. Enter solution components – the artisans shaping the Dynamics 365 landscape. From customizable tools to APIs, the arsenal at your disposal is vast. And remember, solutions can only add and overwrite components, not erase them.

What Are Solutions and Why Should You Care?

Solutions are like toolkits that let you add new things to Dynamics 365 or change how it works. They're super useful because they help you share your cool creations with others.

Different Kinds of Solutions:

There are two types of solutions - think of them like two flavors. One flavor is "managed," which is like a ready-to-use package, and the other is "unmanaged," which is like a work-in-progress package.

Managed vs. Unmanaged

Picture solutions as dancers on the stage of innovation. Managed solutions, polished and complete, take the spotlight. Unmanaged solutions, the choreographers, are in development. Each dance, whether managed or unmanaged, affects the ultimate symphony of Dynamics 365's behavior.

The Maestro: Solution Publisher

Every masterpiece needs a maestro. In our story, that's the solution publisher. It provides the harmonious prefix for customizations and option values. Managed solutions dance to its tune for distribution and updates, creating a melody of organization-wide coherence.

Managed Properties: Sculpting Customization

Just as a sculptor molds clay, solution creators mold managed properties. These properties decide what's customizable in your solutions. Our guide unveils the secret behind locking down definitions for stability or keeping the door open for future changes.

Conflict Resolutions: The Art of Balance

Where solutions thrive, conflicts may arise. Our guide hands you the brush to paint resolutions. Merge or top wins? The canvas of user interface components unveils strategies to keep your Dynamics 365 masterpiece harmonious.

Dependencies: Threads of Unity

In the grand tapestry of Dynamics 365, dependencies weave threads of unity. Our guide explains how they ensure the system's integrity. Deleting, exporting, or importing, you'll be well-versed in preserving the harmony.

Linguistic Elegance: Multilingual Mastery

Dynamics 365's multilingual prowess elevates your solutions. Language packs add a symphony of languages to user interface elements. Our guide showcases how to seamlessly conduct this linguistic orchestra. 

Wednesday, August 23, 2023

Auto Populate and Concatenate Field using Processes | Dynamics 365

How to Auto Populate and Concatenate Field using Processes in Dynamics 365?


Follow the video below to see the implementation.


In Dynamics 365, you can use processes to automate various tasks, including auto-populating fields. The process automation tool in Dynamics 365 is known as Power Automate (previously known as Microsoft Flow). Power Automate allows you to create workflows that can automate actions and trigger processes based on certain conditions.

Updating with a detailed process with a snapshot soon...

Sunday, August 20, 2023

Auto Populating Field using Business Rule | Dynamics 365

How to Auto Populate Field using Business Rule in Dynamics 365?

Follow the below video to see the full implementation-
In Dynamics 365, a Business Rule is a tool that allows you to define and apply logic to automate and customize the behavior of your CRM system. It lets you set up conditions and actions without writing code, enabling you to create a set of if-then-else statements to guide user interactions and data manipulation. Business Rules are particularly useful for enforcing data validation, controlling field visibility, and triggering automatic field value changes based on user input or other conditions.

By combining conditions and actions, you can do any of the following with business rules:

  • Set field value
  • Clear field values
  • Set field requirement levels
  • Show or hide fields
  • Enable or disable fields
  • Validate data and show error messages
  • Create business recommendations based on business intelligence.

Set up an Auto Populating Field with a Business Rule in Dynamics 365:

Make sure that you have the System Administrator or System Customizer security role or equivalent permissions.

1. Access Business Rules:
Log in to your Dynamics 365 instance and navigate to the entity (record type) where you want to create the Business Rule.

Open solution explorer.

2. Create a New Business Rule:

   - In the entity's customization area, go to the "Business Rules" section.

   - Click on "New" to create a new Business Rule.


The Business Rule designer window opens with a single condition already created for you. Every rule starts with a condition. The business rule takes one or more actions based on that condition.



3. Define Conditions:

-Drag the Condition component from the Components tab to a plus sign in the designer.

-To set properties for the condition, click the Condition component in the designer window, and then set the properties in the Properties tab on the right side of the screen. As you set properties, an expression is created at the bottom of the Properties tab.

-To add an additional clause (an AND or OR) to the condition, click New in the Properties tab to create a new rule, and then set the properties for that rule. In the Rule Logic field, you can specify whether to add the new rule as an AND or an OR.

-When you're done setting properties for the condition, click Apply.

4. Add Actions:

   - Under the "Actions" section, add an action that will be triggered when the condition is met.

   - Select the action type "Set field value" to populate a field automatically.

   - Choose the target field you want to populate and set its value based on your predefined condition.

5. Define Actions and Values:

   - For the selected field, set the value you want to populate when the condition is met. This could be a fixed value, a formula, or a value from another field.

6. Apply and Publish:

   - Save your Business Rule configuration.

   - Publish the changes for the entity to make the Business Rule active.

7. Test the Business Rule:

   - Create or edit a record in the entity you configured the Business Rule for.

   - Input the necessary data to meet the condition you defined in the rule.

   - Verify that the target field is automatically populated based on the condition you specified.

8. Adjust and Fine-Tune:

   - If needed, revisit the Business Rule settings to adjust conditions, actions, or values.

   - Test the rule thoroughly with different scenarios to ensure it works as expected.

It's important to note that the exact steps might vary slightly based on the specific version of Dynamics 365 you are using and the customization options available in your instance. Always refer to the official documentation or user guides provided by Microsoft for detailed and up-to-date instructions.




Wednesday, August 16, 2023

Interview questions for Dynamics 365 Developer

Interview questions for Dynamics 365 developer role for 2+ year experience

1. Basic Interview Questions

2. More Technical Questions

3. Plugin Question with code

(Scroll Down for Answers)

1. Basic Interview Questions

**Dynamics 365 Technical Expertise:**

1. Can you explain the difference between Dynamics 365 CE (Customer Engagement) and Dynamics 365 Finance and Operations?

2. What are plugins and how are they used in Dynamics 365?

3. Describe the purpose of Business Process Flows in Dynamics 365 and how you've utilized them in your previous projects.

4. How do you handle data migration and integration tasks in Dynamics 365 projects?

5. Explain the concept of custom entities and how you've designed and implemented them.

6. What are Web Resources in Dynamics 365? Provide examples of scenarios where you've used them effectively.

7. How do you ensure security and data privacy within Dynamics 365 applications?

**Development and Customization:**

1. Can you walk us through your process of designing and implementing custom workflows in Dynamics 365?

2. Describe your experience with creating and maintaining custom reports and dashboards in Dynamics 365.

3. Have you worked with JavaScript and TypeScript in Dynamics 365 development? Give examples of how you've used client-side scripting to enhance user experience.

4. How do you approach designing and implementing solutions that involve both on-premises and cloud-based Dynamics 365 instances?

5. Have you integrated Dynamics 365 with external systems? What tools or methods have you used for this?

6. Explain how you handle version control and deployment in Dynamics 365 projects.

7. Can you discuss an instance where you had to optimize the performance of a Dynamics 365 application? What approaches did you take?

**Problem Solving and Troubleshooting:**

1. Describe a challenging bug or issue you encountered in a Dynamics 365 project and how you went about identifying and resolving it.

2. How do you approach debugging and diagnosing issues in a Dynamics 365 environment?

3. Have you worked with Azure DevOps or similar tools for managing Dynamics 365 projects? Describe your experience.

4. What strategies do you use to ensure the reliability and availability of a Dynamics 365 application during updates and maintenance?

**Communication and Collaboration:**

1. Can you provide an example of a situation where you had to communicate technical concepts to non-technical stakeholders?

2. How do you collaborate with functional consultants, business analysts, and other team members in a Dynamics 365 project?

3. Describe a time when you had to manage conflicting priorities or requirements within a Dynamics 365 development project.

**General Knowledge:**

1. What are the latest updates or features in the most recent version of Dynamics 365? How do they impact development?

2. How do you stay updated with the latest trends and best practices in Dynamics 365 development?

3. Can you discuss any experience you have with Microsoft Power Platform and its integration with Dynamics 365?

--------------------Answers --------------------

**Dynamics 365 Technical Expertise:**

1. Dynamics 365 CE focuses on customer relationship management, while Dynamics 365 Finance and Operations deals with enterprise resource planning. CE handles sales, customer service, and marketing, while Finance and Operations manage financials, supply chain, and manufacturing.

2. Plugins are custom code snippets that extend the functionality of Dynamics 365. They are triggered by specific events and can interact with data and perform actions, allowing for custom business logic.

3. Business Process Flows guide users through predefined processes, ensuring consistent and organized data entry and interactions. For instance, I used them to streamline lead-to-opportunity processes.

4. Data migration involves transferring data from one system to another, often using tools like Data Import Wizard or Data Migration Assistant. Integration involves connecting Dynamics 365 with external systems, usually utilizing APIs and middleware.

5. Custom entities are data structures tailored to specific business needs. I've designed custom entities for specialized objects like equipment, projects, or events.

6. Web Resources are files like HTML, JavaScript, or CSS that can be used in Dynamics 365 forms, dashboards, and other areas to enhance user experience and functionality.

7. Security roles, field-level security, and record-based security are methods to control access to data in Dynamics 365, ensuring that users see only what they're authorized to.

**Development and Customization:**

1. Custom workflows automate business processes by defining a series of steps. I've used them to automate lead qualification and approval processes.

2. I've used tools like Power BI to create custom reports and dashboards in Dynamics 365, providing insights into sales trends and customer interactions.

3. Yes, I've used JavaScript to enhance the client-side functionality of Dynamics 365 forms. For example, I've implemented form validation and dynamic field updates.

4. For hybrid environments, I've integrated on-premises Dynamics 365 instances with the cloud using Azure Service Bus or Azure Logic Apps for data synchronization.

5. I've integrated Dynamics 365 with external systems using RESTful APIs and Azure Logic Apps. For example, syncing customer data between Dynamics 365 and a marketing automation platform.

6. I use solutions and version control tools like Azure DevOps to manage changes and deployments in Dynamics 365 projects, ensuring a controlled release process.

7. I optimized performance by using caching mechanisms, optimizing queries, and minimizing the use of synchronous plugins. For larger datasets, I employed batch processing.

**Problem Solving and Troubleshooting:**

1. In one project, a synchronization issue caused data discrepancies between Dynamics 365 and an external system. I debugged the integration code, identified the root cause, and applied necessary adjustments to ensure data consistency.

2. I use platform tracing and debugging tools to identify issues. I follow a systematic approach, analyzing error messages, reviewing logs, and isolating the problematic code.

3. I've used Azure DevOps to manage project tasks, code repositories, and continuous integration/continuous deployment (CI/CD) pipelines, enabling seamless collaboration among team members.

4. During updates, I ensured high availability by utilizing rolling updates, performing thorough testing in a staging environment, and monitoring the system closely after deployment.

**Communication and Collaboration:**

1. I conveyed complex technical concepts to non-technical stakeholders by using clear analogies and visual aids, focusing on the business impact of the technology.

2. I collaborate with functional consultants to understand business requirements and translate them into technical solutions. Regular meetings and shared documentation help maintain alignment.

3. When facing conflicting priorities, I initiate open discussions with stakeholders, emphasizing the importance of balancing immediate needs with long-term system integrity.

**General Knowledge:**

1. In the latest version, Dynamics 365 introduced AI-powered insights, enhanced integration with Microsoft Teams, and improved mobile experiences, among other features.

2. I stay updated by attending conferences, participating in online communities, and reading Microsoft's official documentation and blogs.

3. I have experience with Power Platform components such as Power Apps and Power Automate, using them to create custom solutions that extend Dynamics 365's capabilities.

2. More technical questions

**Dynamics 365 Customization and Development:**

1. Explain the differences between real-time workflows and asynchronous workflows in Dynamics 365. When would you choose one over the other?

2. How do you register a custom plugin in Dynamics 365? Can you provide an example of a scenario where you've used a plugin to extend functionality?

3. What is the purpose of the FetchXML query in Dynamics 365? Provide an example of a situation where you would use FetchXML.

4. How would you implement client-side validation for a specific field on a Dynamics 365 form? What are the advantages of using client-side validation?

5. Describe your experience with Business Rules in Dynamics 365. When would you use Business Rules versus plugins or custom code?

6. How do you secure sensitive data in Dynamics 365? Explain the process of implementing field-level security for specific records.

**Integration and Custom Web Resources:**

1. Can you outline the steps to create a custom Web API endpoint in Dynamics 365? What are some scenarios where you might use a custom Web API?

2. Discuss the process of integrating Dynamics 365 with an external service using Azure Logic Apps. What considerations should be taken into account?

3. How would you embed a custom HTML web resource into a Dynamics 365 form? Provide an example of how you've used custom web resources to enhance user experience.

4. Explain the purpose of virtual entities in Dynamics 365. How would you set up a virtual entity to display data from an external system?

**Performance Optimization and Troubleshooting:**

1. What are some techniques you've used to improve the performance of Dynamics 365 forms and views, especially in scenarios with large datasets?

2. Describe a situation where you encountered a plugin causing a performance bottleneck. How did you identify and address the issue?

3. How would you approach troubleshooting a situation where a Dynamics 365 workflow isn't firing as expected? What tools or methods would you use?

**Advanced Dynamics 365 Concepts:**

1. Explain the concept of Business Process Flows branching and stages in Dynamics 365. How have you implemented complex branching logic in your projects?

2. What are Business Units in Dynamics 365? How can they be utilized to manage security and data access in a complex organization?

3. Describe the use of Power Automate (previously Microsoft Flow) in Dynamics 365 integration scenarios. Provide an example of a flow you've created.

--------------------Answers --------------------

**Dynamics 365 Customization and Development:**

1. Real-time workflows execute immediately after a specified event occurs, while asynchronous workflows are queued for background processing. Choose real-time workflows for immediate user interaction and asynchronous workflows for non-urgent, background processes like sending emails.

2. To register a custom plugin, you create a class that implements the IPlugin interface, compile it into a DLL, and then use the Plugin Registration Tool to deploy it to Dynamics 365. An example scenario could be a plugin that triggers on opportunity creation to validate data and perform additional calculations.

3. FetchXML is a query language used to retrieve data from Dynamics 365. An example scenario is querying for all accounts where the industry is "Technology" and the revenue is greater than $1 million.

4. Client-side validation can be implemented using JavaScript. You attach an event handler to the field's onchange event, perform validation logic, and provide user-friendly error messages. Client-side validation reduces server round-trips and provides instant feedback to users.

5. Business Rules are used for simple form logic without writing code. For complex logic or scenarios requiring data manipulation, plugins or custom code are preferable.

6. Field-level security restricts access to specific fields for certain users or teams. You enable field-level security, define security profiles, and associate them with users or teams. This prevents unauthorized users from viewing or modifying sensitive data.

**Integration and Custom Web Resources:**

1. To create a custom Web API endpoint, you define a Web API function in a custom action, create a custom plugin to handle the action, and then expose it through the Web API. An example scenario could be creating a custom Web API to retrieve related contact information for an account.

2. Integration using Azure Logic Apps involves creating a workflow that connects to Dynamics 365 and external systems through connectors. Considerations include authentication, error handling, and data transformation.

3. To embed a custom HTML web resource into a Dynamics 365 form, you create an HTML file and upload it as a web resource. You then reference this web resource within the form. An example scenario could be embedding a custom map visualization using HTML and JavaScript.

4. Virtual entities allow you to view and interact with external data in Dynamics 365 without physically storing it. You set up a connection to the external data source, define the entity structure, and map attributes. For instance, you could use a virtual entity to display recent social media posts related to an account.

**Performance Optimization and Troubleshooting:**

1. Techniques to improve form and view performance include optimizing fetch queries, using filtered views, enabling caching, and minimizing the number of visible fields and columns. Implementing asynchronous plugins and leveraging data virtualization also help.

2. If a plugin causes performance issues, I'd start by profiling the plugin's execution time and resource usage. I'd review the plugin logic for any unnecessary actions, database queries, or loops that could be optimized. Profiling tools like XrmToolBox's Plugin Trace Viewer can be valuable.

3. Troubleshooting a workflow involves checking the workflow's activation conditions, logic, and related data. Using the built-in workflow tracing and enabling tracing in the Dynamics 365 settings can provide insights into why the workflow isn't firing as expected.

**Advanced Dynamics 365 Concepts:**

1. Business Process Flow branching allows different paths based on conditions. Stages represent a phase within the process. Complex branching can be achieved by defining multiple paths within stages and using conditional branching at the stage level.

2. Business Units in Dynamics 365 are logical containers that help organize data and security settings. They're useful for managing different divisions or departments within an organization. Security roles and data access can be configured based on the business unit hierarchy.

3. Power Automate can be used to automate processes across different systems, including Dynamics 365. An example flow could automate lead-to-opportunity conversion by triggering a flow when a new lead is created and then creating a corresponding opportunity in Dynamics 365.

These answers aim to showcase a deep understanding of the technical aspects of Dynamics 365 development and customization. Keep in mind that you can elaborate further based on your own experiences and project contexts.


3. Plugin Question with code

1. On Opportunity form

  1. When the Opportunity is saved do a simple check using Plugin that Customer’s Monthly Salary is Defined and is more than $5,000.

  2. Create a field Monthly Income of type currency on the Contact entity to capture its Monthly Salary.

  3. If the Salary is less than $5,000, then the Opportunity should not be created.


2. To create a plugin for a button that enables bulk edit of records in Dynamics 365, you can follow these general steps: (chatgpt solution)
  • Create a custom button on the entity form where you want to enable bulk edit.
  • Create a new plugin using Visual Studio or any other development tool that supports .NET framework and the Dynamics 365 SDK.
  • In the plugin code, define the steps to retrieve the records to be bulk edited, and perform the desired operations on those records.
  • In the plugin registration tool, register the plugin to execute when the custom button is clicked.

3. Pre-populate field

4. Plugin to update all the related contacts of a specific account when a specific field on account record has been updated

Description: Following are the details of what needs to be covered:

  1. Make sure we have Account to Contact (1:N) relationship setup calling the subgrid as

Related Contacts

  1. Create a new field in Account and Contact both called as “Payment Type” which is an

optionset field having options as {Cash, Debit Card, Credit Card}

  1. Create a plugin on the Account entity which will be registered on the “Update” of the “Payment Type” field.

  2. Plugin logic will include the following steps:

  1. Retrieve all related Contacts corresponding to Account in context

  2. Update “Payment Type” field on all the Contacts same as what has been set on

the updated Account record


Plugin code


-----------------------------------------1----------------------------------------



-----------------------------------------2----------------------------------------

using Microsoft.Xrm.Sdk;

using Microsoft.Xrm.Sdk.Query;

using System;


namespace MyPluginNamespace

{

    public class BulkEditPlugin : IPlugin

    {

        public void Execute(IServiceProvider serviceProvider)

        {

            // Obtain the execution context from the service provider.

            IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));


            // Check if the plugin is executed from the custom button click event.

            if (context.MessageName.ToLower() != "my_custom_button_name")

                return;


            // Obtain the organization service from the service provider.

            IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));

            IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);


            // Define the query to retrieve the records to be bulk edited.

            QueryExpression query = new QueryExpression("my_entity_name");

            query.ColumnSet = new ColumnSet(true); // Include all columns.

            // Add any necessary conditions to limit the records to be edited.

            // For example, you might want to retrieve only records that meet certain criteria or that belong to a certain view.


            // Retrieve the records to be edited.

            EntityCollection results = service.RetrieveMultiple(query);


            // Perform the bulk edit operations on each retrieved record.

            foreach (Entity record in results.Entities)

            {

                // Update the record as needed.

                // For example, you might want to set a field value, clear a field value, or perform some other operation.

                // You can use the service.Update() method to update the record in the database.

            }

        }

    }

}


Note that you will need to replace my_custom_button_name with the name of your custom button, and my_entity_name with the name of the entity you want to bulk edit. You will also need to add any necessary conditions to the query to retrieve only the records you want to edit. Finally, you will need to test the plugin thoroughly to ensure that it behaves as expected and does not cause any unintended side effects.



-----------------------------------------4----------------------------------------

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using Microsoft.Xrm.Sdk;

using Microsoft.Xrm.Sdk.Query;

namespace KervDemo

{

    public class UpdatePaymentTypeInAssociateContact : IPlugin

    {

        public void Execute(IServiceProvider serviceProvider)

        {

            ITracingService tracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));

            IPluginExecutionContext context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));

            IOrganizationServiceFactory serviceFactory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));

            IOrganizationService crmService = serviceFactory.CreateOrganizationService(context.UserId);


            if (context.InputParameters.Contains("Target") && context.MessageName.ToUpper() == "UPDATE")

            {

                Entity entity = context.InputParameters["Target"] as Entity;

                

                OptionSetValue paymentTypeValue = entity.Attributes.Contains("kerv_paymenttype") ?

                    entity.GetAttributeValue<OptionSetValue>("kerv_paymenttype") : null;

                int paymentType = paymentTypeValue.Value;

                //Fetch Contact Records using Query Expression


                QueryExpression qe = new QueryExpression("contact");

                qe.Criteria.AddCondition("parentcustomerid", ConditionOperator.Equal, entity.Id);

                EntityCollection relatedContacts = crmService.RetrieveMultiple(qe);

                if(relatedContacts != null && relatedContacts.Entities.Count > 0)

                {

                    foreach(var contact in relatedContacts.Entities)

                    {

                        Entity entity = new Entity(contact.LogicalName, contact.Id);

                        entity1["kerv_paymenttype"] = new OptionSetValue(paymentType);

                        crmService.Update(entity1);

                    }

                }

            }

        }

    }

}



Tuesday, August 15, 2023

Create Trial Instance in Dynamics 365

Q. How to create Create Sales Trial Instance in Dynamics 365?

Follow the below video to see the full implementation-

A trial instance refers to a temporary environment that allows users to explore and evaluate the features and capabilities of the Dynamics 365 applications It's a way for organizations to test the software, understand its functionality, and determine if it meets their specific business needs before deciding to subscribe to a paid version. 

This lets them understand how the program functions and if it fits their needs before they decide to pay for it. They can play around with it, learn how it works, and decide if they want to use it for their real work. It's like a "try before you buy" opportunity for businesses to make sure they're making the right choice.

Note- As trials are limited to 30 days, it's advisable to wait until you have sufficient time to dedicate to working within the trial.

Prerequisites: To set up a Dynamics 365 trial, you'll require a Microsoft account. If you don't have an existing Microsoft account or wish to create a new one, you can begin the process on the official Microsoft website.

Explore various modules available in the free trial version. You can access all of them right here
URL - https://trials.dynamics.com/

Creating a Trial Instance in Dynamics 365

Follow these detailed steps to set up a trial instance in Dynamics 365:
Step 1: Start by opening your web browser and click on the following link to access the Dynamics 365 Marketing Home Page: Link here This link will take you to the main page where you can initiate the trial setup process.

Step 2: On the Dynamics 365 Trial Home Page, locate and click on the "Try for free" option under Sales Module. This will be a clickable button or link that's designed to start the trial registration process.
Step 3: You'll be prompted to provide your email address. It's important to use your Microsoft account ID for this step. Note that non-Microsoft email accounts won't be accepted for the trial. Once you've entered your Microsoft account email, click on the "Start your free trial" button to proceed.

Step 4: After clicking the "Start your free trial" button, you'll be asked to enter the password associated with your Microsoft account. This is a security measure to ensure the authenticity of your request. Once you've entered your password, click on the "Sign in" button. After signing in, you might need to click "Submit" to confirm your information.

Step 5: Now it's time to add your personal information. Fill out the form with the required details about yourself. This information might include your name, contact information, and any other necessary details. Once you've completed the form, click "Next" to proceed.

Step 6: After submitting the form, you'll be directed to a new page. Here, you'll receive a confirmation that Microsoft is in the process of creating your trial instance. This might take a moment. 

Step 7: Once the trial instance is fully created, you'll see an option to "Launch Trial." Click on this option to access your newly created Dynamics 365 Sales trial instance.


Step 8: Congratulations! Your Dynamics 365 Sales trial instance is now accessible and ready for use. You can begin exploring the features and functionalities offered by Dynamics 365 to support your work and business needs.


By following these detailed steps, you'll successfully create a trial instance of Dynamics 365 Sales and be on your way to utilizing its capabilities for your tasks and projects.

Go to the Power Platform Admin Center at https://admin.powerplatform.microsoft.com/home 
Click on "Environments" to view the Trial Environments and add a new one by selecting the "Add new" button.

Followers

Power Dynamix YouTube Videos