Thursday 25 January 2018

CRM Portals - Add Hyperlink On Custom Attribute In Entity List












By default, In Entity List If you enable settings to view Entity List records, It shows hyperlink only on very First Column of Entity List.

Refer below link to configure Details View Setting (to view entity list record) in Entity List.

https://community.adxstudio.com/products/adxstudio-portals/documentation/configuration-guide/entity-list/view-details-page/

https://community.dynamics.com/crm/b/nishantranaweblog/archive/2017/02/02/using-entity-list-to-show-crm-data-in-portal-in-dynamics-365




For Example - In above example, I have exposed Case Entity List on Portal, It showing hyperlink on only Case Number, But If I want to make the hyperlink on any other Field it is not possible Out of Box.

So In this article, I will walk you through the way to make the other Column Value Hyperlink of any Entity List in Portal.


Code Snippet:


$('.entitylist').on("loaded", function () {

//To make the other field/column's value hyperlink
$("td[data-attribute*='Field's SCHEMA NAME or Field's HTML Control Id']").each(function() {

// For Example
$("td[data-attribute*='title']").each(function() {

// Get guid of record - might need to change this line a bit to get the record guid
var id=$(this).closest('tr').attr("data-id");

// Partial URL of webpage where you want to redirect the user or the page from which your Edit Entity Form is associated
var pagewhereToRedirect = "Web page Partial URL";

var pagewhereToRedirect = "edit-case"; // For Example

// Construct the URL
var redirect=window.location.href+pagewhereToRedirect+"/?id="+id;

// Make the field value Hyperlink
var text=$(this).text();

$(this).html("<a href="+redirect+">"+text+"</a>");

});

});


Note: In above code, you just need to change the highlighted value only.

To get Field's SCHEMA NAME or Field's HTML Control Id

Press F12 or Right Click  >  Inspect





















To get Web page Partial URL

Right Click on Hyperlink and Copy Link Address. The highlighted part is the partial URL of the webpage.

https://arpitdynamics.microsoftcrmportals.com/support/edit-case/?id=2c29a2bb-bb01-e811-90cd-0003ff913670









Sunday 21 January 2018

Pre-Image and Post-Image in Dynamics CRM



What is Pre and Post Images in CRM?

In Real Life,

Let's understand the Images in CRM by taking one real-life example of ATM Withdrawal Process:

Suppose, I have 10,000 Rs in my bank account. So this amount would be the Pre-Image of my account balance. Now, If I withdraw 5000 Rs from my account, then the remaining amount left in my account would be 5000 Rs. So the current amount left in my account would be the Post-Image of my account balance.

Here

Pre-Image of my Account Balance = 10,000 Rs
Performing Database Transaction
Transaction Done (Core Operation) of 5000Rs
Post-Image of my Account Balance = 5000 Rs

In CRM,
  • Images are the snapshots of the entity's attributes, before and after the core system operation. 
  • PreEntityImages contain snapshots of the primary entity's attributes before the core platform operation perform and PostEntityImages contains the snapshot of the primary entity's attributes after the core platform operation performed.
Let say: I have a contact record in the CRM with FirstName and LastName as Arpit and Shrivastava respectively. Suppose I change the values of both the field as Mike and Hussey respectively. Then the  Pre-Image of FirstName and LastName would be Arpit and Shrivastava respectively while the Post-Image of FirstName and LastName would get Mike and Hussey respectively.


Difference between Plugin Context and Plugin Images? 



Context means Current.

Context contains the entity business information which is being updated currently on CRM Platform.

In Plugin,

IPluginExecutionContext contains information that describes the run-time environment that the plug-in executes, information related to the execution pipeline, and entity business information.

When a system event is fired that a plug-in is registered for, the system creates and populates the context and passes it to a plug-in through the previously mentioned classes and methods. The execution context is passed to each registered plug-in in the pipeline when they are executed.

Context Example - 

Let say. I have a plugin registered on Update of Contact Entity, If I update only Firstname and Lastname of contact record then plugin code can get only Firstname and Lastname field's value from the Plugin Context along with the information related to the execution pipeline.

But If I want to get the other field's value like emailaddress and account name from plugin context, we will not be able to get the same and will get the error 'The given key was not present in the dictionary' error.

To get these values, either we will have to perform retrieve query or can achieve it through pre-images.

So Images are the best ways to get the copy of data (from whatever fields you want) before and after changes made to the database or changes committed to the database. While from context we can get the updated field's values only

Advantages of using Pre-Image and Post-Image in CRM?

One of the best uses for this is in update plug-ins. 

  • In update plug-in, target entity only contains the updated attributes. However, often the plug-in will require information from other attributes as well. Instead of issuing a retrieve, the best practice is to push the required data in an image instead.

For Example- I have a plugin trigger on Update of Account's email address and website fields. 

Logic is if any user updates the account's email address and website URL then, create a task with the updated email address and website URL along with account name and its parent account.

To implement this logic in my plugin, I can get account's email address and website URL from Context while account name and parent account.not. Because the user has updated only account's email address and website URL not rest of the account's data. So Plugin Context contains only updated information instead of unchanged information.

So how would I get the account's account name, parent account or any other data?

Option 1- Perform Retrieve Query to get rest of account information.

Option 2- Use Pre-Image and configure the fields from which we want to pull the information without performing any query on the database.

  • Comparison of data before and after. This allows for various audit-type plugins, that logs what the value was before and after, or calculating the time spent in a stage or status.


When the different images are available in the event execution pipeline? 






Plugin Image Example:

Let understand the plugin code by taking a very simple example- 

Whenever a user updates the emailaddress and topic(subject) on the Lead entity, we want to get the old and new value respectively of the topic field before and after the changes made in the database. And update both the values in the description field.

So here, the old value of topic field would be called as pre-image and the new value of topic field would be called as post image.

Register a Plugin on Update of Lead 'Email Address' Field.

























Register a new Image on Update Step



















Select 'Topic' from the Field List. Because we want to get the Pre and Post Image of Topic Field.



























Give Image name and check PreImage and PostImage checkbox



You can specify to have the platform populate these PreEntityImages and PostEntityImages properties when you register your plug-in. The entity alias value you specify during plug-in registration is used as the key into the image collection in your plug-in code


















using Microsoft.Xrm.Sdk;

using Microsoft.Xrm.Sdk.Query;

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;


namespace PluginImageExample
{

 public class LeadUpdate : IPlugin

  {

    public void Execute(IServiceProvider serviceProvider)

    {

    // Extract the tracing service for use in debugging sandboxed plug-ins.

    ITracingService tracingService =

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


    // Obtain the execution context from the service provider.

    IPluginExecutionContext context = 

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


    // Obtain the organization service factory.
    
    IOrganizationServiceFactory serviceFactory = 

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

    
    // Obtain the organization service.    
    IOrganizationService service = serviceFactory.CreateOrganizationService(context.UserId);


    if (context.InputParameters.Contains("Target") && 

                  context.InputParameters["Target"] is Entity)

     {

        // Obtain the target entity from the input parameters.

         Entity entity = (Entity)context.InputParameters["Target"];

        // User is updating only email address in lead form so we will get only 
           emailaddress from the context not lead's description.To get description
           orsubject field we will use plugin images
     
        // get the lead email from context.

         string email = entity["emailaddress1"].ToString();

        // get the current record guid from context

         Guid leadRecordGuid = entity.Id;

       
// Define variables to store Preimage and Postimage string pretopic = string.Empty; string posttopic = string.Empty;

        // in below leadimage has been added in plugin registration tool

        // get PreImage from Context

          if (context.PreEntityImages.Contains("LeadTopicImage") && 
                context.PreEntityImages["LeadTopicImage"] is Entity)
          {

               Entity preMessageImage = (Entity)context.PreEntityImages["LeadTopicImage"];

               // get topic field value before database update perform
pretopic = (String)preMessageImage.Attributes["subject"]; } // get PostImage from Context

            if (context.PostEntityImages.Contains("LeadTopicImage") && 
                   context.PostEntityImages["LeadTopicImage"] is Entity)

            {

              Entity postMessageImage = (Entity)context.PostEntityImages["LeadTopicImage"];

            // get topic field value after database update performed
posttopic = (String)postMessageImage.Attributes["subject"]; } // update the old and new values of topic field in description field

          Entity leadObj = 
          service.Retrieve(context.PrimaryEntityName,leadRecordGuid, new ColumnSet("description"));

          leadObj["description"] = 
          "Pre-Image of description- "+pretopic+"   "+"Post-Image of description-- "+posttopic;

          service.Update(leadObj);

           }

        }

    }

}


Let's test the functionality. Open any existing Lead record.




















Update Email and Topic field's value and Save the record.





















Check the 'Description' field. It has been updated with old and new value both of Topic Field.




Points to Note:

                                      
  • Microsoft Dynamics 365 populates the pre-entity and post-entity images based on the security privileges of the impersonated system user. Only entity attributes that are set to a value or are null are available in the pre or post entity images. 
  • There are some events where images aren’t available. For example, only synchronous post-event and asynchronous registered plug-ins have PostEntityImages populated. The create operation doesn’t support a pre-image and a delete operation doesn’t support a post-image.
  • Registering for pre or post images to access entity attribute values results in improved plug-in performance as compared to obtaining entity attributes in plug-in code through RetrieveRequest or RetrieveMultipleRequest requests.
  • A pre-image passed in the execution context to a plug-in or custom workflow activity might contain data that the logged-on user doesn't have the privileges to access. Microsoft Dynamics 365 administrators and other users with high-level permissions can register plug-ins to run under the “system” user account or plug-in code can make calls as a “system” user on behalf of the logged-on user. If this happens, logged-on users can access data that their field level security does not allow access to.
  • Context contains only updated field's value information of any record. While the Pre-Image contains all the field's values information (depends on what field you are being opted to be available as pre-images)


Cheers😎

Saturday 20 January 2018

Automatically Assign Webrole to the Contacts in CRM Portals

Once a contact has been configured to use on the portal, it must be given one or more web roles in order to perform any special actions or access any protected content on the portal.

For more information about the creation and assigning of web roles to Portal Users. Refer below link:

https://community.adxstudio.com/products/adxstudio-portals/documentation/configuration-guide/content-authorization/web-roles/

https://docs.microsoft.com/en-us/dynamics365/customer-engagement/portals/create-web-roles

In a lot of scenarios, you might have a requirement to assign the web roles as soon as portal user or contact creates in CRM.

Few Scenarios are-
  • If we want to automatically assign a web role to the users after successful registration on the portal.
  • if we want to automatically change the web role of a user on user request.For example, if a portal user gets promoted from Sales Person to Sales Manager, He might request to elevate his/her role.
  • If we want to automatically remove the access to a user, if he/she meets certain conditions like- User has not yet updated his/her profile or email address.


So there might be a lot of case where we need to automatically assign/change/remove the access to the portal users.


Let's take a very simple example - Assign 'Authenticated Role' and Remove 'Administrator Role' to the user as soon as his/her contact gets created in CRM.


Step 1: Create a new System Workflow or Process (Settings > Process > New)
















Step 2: Add new step - Portals > Assign Web Role and Unassign Web Role
















Step 3: Click on 'Set Properties' on first and second step respectively. 

Associate 'Authenticate Role' to the first step and 'Administrator Role' to the second step in order to assign and remove the authenticated and administrator role respectively.




















Step 4: If you want to assign/remove/change the user role whenever user/contact is being created from Portal instead of CRM. 

Put below condition and then Activate the workflow:


































Idea! 

By making this workflow on-demand, you can assign web roles to the multiple contacts simultaneously.


Please do not forget to share your feedback. Thank in advance.

Cheers 😎

Saturday 13 January 2018

Configure Knowledge Articles In CRM Portals

Image result for knowledge articles
Knowledge Base





















The Knowledge Base is designed to assist customer service representatives as they answer questions and resolve cases. It is a repository of information that is used by the customer service team but is visible to everyone. It consists of articles (documents) that are categorized by subjects.
To get more details about Knowledge Articles in Dynamics 365 refer below article:



In this article, I will show you how to configure Knowledge Articles in CRM Portals.

Suppose we have installed the Customer Portal in our CRM instance and we want to configure Knowledge Base articles with the Portal. 

By default, you see below content as soon as you click on 'Knowledge Base' from the toolbar.

Because Knowledge Base is yet to configured in Dynamics 365 for your Portal instance.


Go to Settings > Service Management > Embedded Knowledge Search














Specify the Portal URL and other settings as per below instruction














Create few sample articles in CRM. Go to Service > Knowledge Articles. For Example -I have created two articles as mentioned below.











Once the setup is done, go to Support page in the portal and perform a search.




















Clicking on the search result opens up the article in the portal.




















Can refer below article to customize OOB knowledge articles in CRM Portals. 


Cheers 😎

Configure Multiple Languages in CRM Portals




















Looking to translate your CRM Portal Website in different languages? You've come to the right place! It broadens your audience, expands your horizons and increases your revenue by opening up to the world.

The Internet has a worldwide reach, it's true. Yet, not everyone speaks or understands English. If you want to reach several different markets around the world, translating and localizing your website and marketing content is essential.

If you're still in doubt about how translation and localization will help you reach your company's growth goals, take a look at this list we've compiled; the top 5 benefits of having a multilingual website:

1- Effectively reach any target market. Users will be encouraged to visit your site if it is in their own language. Non-English speaking customers tend to veer away from English-only sites, as they cannot get all the information that they need.

2- Reach more Customers cost-effectively. A multilingual site is cost-efficient. Since your site is available in several languages and countries, you get to reach more people in your target market without having to spend more money.

3- More customers = Higher conversion. Customers like to feel important and if yours believe that you’ve taken the time to study their tastes, needs and language requirements, they’ll be more inclined to purchase your services.

4- Build trust among your customers. Localization generates trust. After all, would you do business with a company whose language you didn’t understand and whose terms and conditions were unclear? Not only will customers appreciate your website being tailored to their needs, but they’ll be far more likely to trust in a company who speaks their own language.

5- Get One Up On The Competition. Search these days is local and if your customers in different target markets are using local search terms to find what they’re looking for, your site will appear higher in their search. Kiss the competition goodbye if they’re working with a monolingual site.

































Supported languages in CRM Portals?

The table below shows all the languages currently available out of the box. This list can be found in Dynamics 365 by going to Portals > Content > Portal Languages. The Portal Display Name of a language can be changed after selecting the language to change from this page. Note that the list now includes East Asian languages (Japanese, Chinese, and Korean).

NameLanguage CodeLCIDPortal Display Name
Basque - Basqueeu-ES1069euskara
Bulgarian - Bulgariabg-BG1026български
Catalan - Catalanca-ES1027català
Chinese - Chinazh-CN2052中文(中国)
Chinese - Hong Kong SARzh-HK3076中文(香港特別行政區)
Chinese - Traditionalzh-TW1028中文(台灣)
Croatian - Croatiahr-HR1050hrvatski
Czech - Czech Republiccs-CZ1029čeština
Danish - Denmarkda-DK1030dansk
Dutch - Netherlandsnl-NL1043Nederlands
Englishen-US1033English
Estonian - Estoniaet-EE1061eesti
Finnish - Finlandfi-FI1035suomi
French - Francefr-FR1036français
Galician - Spaingl-ES1110galego
German - Germanyde-DE1031Deutsch
Greek - Greeceel-GR1032Ελληνικά
Hindi - Indiahi-IN1081हिंदी
Hungarian - Hungaryhu-HU1038magyar
Indonesian - Indonesiaid-ID1057Bahasa Indonesia
Italian - Italyit-IT1040italiano
Japanese - Japanja-JP1041日本語
Kazakh - Kazakhstankk-KZ1087қазақ тілі
Korean - Koreako-KR1042한국어
Latvian - Latvialv-LV1062latviešu
Lithuanian - Lithuanialt-LT1063lietuvių
Malay - Malaysiams-MY1086Bahasa Melayu
Norwegian (Bokmål) - Norwaynb-NO1044norsk bokmål
Polish - Polandpl-PL1045polski
Portuguese - Brazilpt-BR1046português (Brasil)
Portuguese - Portugalpt-PT2070português (Portugal)
Romanian - Romaniaro-RO1048română
Russian - Russiaru-RU1049русский
Serbian (Cyrillic) - Serbiasr-Cyrl-CS3098српски
Serbian (Latin) - Serbiasr-Latn-CS2074srpski
Slovak - Slovakiask-SK1051slovenčina
Slovenian - Sloveniasl-SI1060slovenščina
Spanish (Traditional Sort) - Spaines-ES3082español
Swedish - Swedensv-SE1053svenska
Thai - Thailandth-TH1054ไทย
Turkish - Turkeytr-TR1055Türkçe
Ukrainian - Ukraineuk-UA1058українська
Vietnamese - Vietnamvi-VN1066Tiếng Việt

Reference https://docs.microsoft.com/en-us/dynamics365/customer-engagement/portals/enable-multiple-language-support


How to configure multiple languages in CRM Portal?


Related image



The following is a step by step guide to enable multi-language in the Dynamics 365 Portal. For demonstration I am configuring Turkish and Hindi languages.

In Dynamics 365, navigate to Settings -> Administration and click on the Languages button.




















You then have a list of languages that you can enable for Dynamics 365.  Choose the language(s) that you want to be available on your portal.














Once selected, click “Apply”.  Note that this is something you should consider doing during a maintenance window.












The language will be enabled.  This may take a while.












The language will be enabled.  This may take a while. 

While you are waiting, might be a good time to sit back and relax with your favourite beverage.













Now that the language is enabled for Dynamics 365, you will now need to enable it for the Portal.  Navigate to the website record (Portals -> Websites)  You will see a sub-grid listing the supported languages.  You will see the language that should match your Dyn365 default language.




On the right side of the sub-grid, click the “+” icon to add additional languages to your portal.  You will be able to choose the languages and also designate if the language is published or not.


















Once save, you should see the language active on web site record.










Once languages activated, Your web pages, web links and content snippets will be cloned for each language you activate.  

















Navigating to the Portal, you will now have a dropdown on the main menu to choose the language that you want to view the portal in.































You can change language of Weblinks content in respective language by following below steps



















Cheers😎

Blogger Widgets