Friday, March 16, 2018

Augmented Reality and Virtual Reality




Here is the quick overview of Augmented Reality and Virtual Reality, also have explained how it is being used today and how it can change the future. Please let me know your comments, share this video if you like and feel free to email me happycodingblog@gmail.com. Description links: If you like this video, please do subscribe, like, share and comment. Please subscribt to Youtube Channel: https://www.youtube.com/channel/UC5I-...

Future of Artificial Intelligence



Have tried to give you the overview of Artificial Intelligence, fields that are using AI, also the Pros and Cons of it. Please let me know your comments, share this video if you like and feel free to email me happycodingblog@gmail.com. Description links: If you like this video, please do subscribe, like, share and comment.

Subscribe to : https://www.youtube.com/channel/UC5I-bCuSyY3MhV_dmfd_RcQ

Wednesday, February 28, 2018

Google's new OS [Fushsia and Flutter]


Have given just the introduction for the Google's new operating system that will replace Android and Chrome OS in future, If you like the video please do subscribe, like, share and comment.

Subscribe to YouTube channel

Email: happycodingblog@gmail.com

Blog: Happy4coding.blogspot.com

Twitter: https://twitter.com/MadhanDevarajan

The technology behind Bitcoin [Cryptography and Blockchain]




Have tried to provide the overview of the technology behind the Bitcoin. If you like the video please do subscribe, like, share and comment. To subscribe YouTube channel : https://www.youtube.com/channel/UC5I-... email: happycodingblog@gmail.com Blog: Happy4coding.blogspot.com Twitter: https://twitter.com/MadhanDevarajan

Introduction to Dynamics CRM


This video will help you understand the basics of Dynamics CRM in just 5 minutes. Description links: If you like this video, please do subscribe, like, share and comment.

Subscribe to YouTube : https://www.youtube.com/channel/UC5I-bCuSyY3MhV_dmfd_RcQ
Happy 4 Coding Blog: Happy4coding.blogspot.com 

Email: happycodingblog@gmail.com

Monday, July 10, 2017

To query the entities in Dynamics CRM from ADX Portal using jQuery

Introduction

This article demonstrates how to query the entities in Dynamics CRM using jQuery call and OData feeds from ADX Portal.

Steps to get records from Dynamics CRM entities:

It is difficult to get the Dynamics CRM Entities from ADX Portal using any Web API call, because that may require authorization token, client id and client secret etc. Also, you will not be able to get any client context or to use XRMServiceToolKit.

ADX Portal user can be just a contact in Dynamics CRM and would not be a user in CRM domain.  In this scenario, he will not be having access to Dynamics CRM entities directly.  He will be able to see the entities that are published in the ADX portal.

Here in the below example the user registers himself with the invitation code created in Dynamics CRM for Portal User having non-CRM domain email address (ex: Yahoo / Gmail / Hotmail).


Step: 1 Create a contact in Dynamics CRM with the external email address and then generate the invitation code for that contact.



Step: 2 With that Invitation code new user can be registered in the ADX portal.




















Step: 3 Select the Dynamics CRM entities that you want to query from ADX Portal. Go to the Portals in Dynamics CRM and then select the Entity list to add entities that are to be published to ADX Portal as OData Feeds.



Step: 4 Also enable Entity Permissions to restrict the OData Feeds can be viewed by logged in Portal User.



Step: 5 Now go to the Custom JavaScript section in Entity list form or Web Page (Portals) use the ajax call for querying the OData feeds as shown below. 



$(document).ready(function (){
    var portaluser = '{{user.fullname}}';
    var filteroption = "fullname eq '" + portaluser + "'";
    var odataUri = "https://<Portal URL>/_odata/Contacts";
    odataUri += "?$filter=" + encodeURIComponent(filteroption);

    // ajax call to OData feeds of Contacts entity with the filter for finding current logged in user’s record
$.ajax({
        type: 'GET',
        contentType: 'application/json; charset=utf-8',
        datatype: 'json',
        url:  odataUri,                          
        beforeSend: function (XMLHttpRequest) {
            XMLHttpRequest.setRequestHeader('Accept', 'application/json');
        },
        async: true,
        success: function (data, textStatus, xhr) {             

           // Getting the company (Account) name that he belongs to
            var companyname = data.value[0].parentcustomerid.Name;
           
            $(".entitylist.entity-grid").on("loaded", function () {
                $(this).children(".view-grid").find("td[data-attribute='new_name']").each(function (i, e){
                    var attrvalue = $(this);

               // To remove other company’s records from the custom entity list view
                 if (!(attrvalue.context.innerText.contains(companyname))){
                        $(this).closest('tr').remove();
                    }
                });
            });
        },
        error: function (xhr, textStatus, errorThrown) {
            alert(textStatus + ' ' + errorThrown);
        }
    });
});

Output:

Measure Details View in CRM Portal:  The output displays only the records belongs to the account he is linked with.



Summary
In this article, I discussed how we can publish the entity as OData feeds and make use of ajax call to find records from the OData feeds. Hope it will be useful for you all, very soon will be back with a new article.  

Tuesday, June 27, 2017

JavaScript For Querying An Entity And Updating Attribute Values In Form

Introduction

This article demonstrates how to query an entity using FetchXML, JavaScript (XRMServiceToolKit), and how to update the form fields on form load or on change event.

Steps to implement JavaScript function in Dynamics CRM Form

JavaScript filename - TotalValueUpdate.js 
  1. function TotalValues(FieldName, TotalFieldName) {  
  2.     var countval = Xrm.Page.getAttribute("new_count").getValue(); // To get the field value of count – used in FetchXML query  
  3.     var quarter = Xrm.Page.getAttribute("new_quarter").getValue(); // To get the field value of quarter – used in FetchXML query  
  4.     quarter = quarter - 1;  
  5.     var FieldValue = Xrm.Page.getAttribute(FieldName).getValue();  
  6.     var fetchXML = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" + " <entity name='new_report'>" + " <attribute name='new_reportid' />" + " <attribute name='new_name' />" + " <attribute name='" + TotalFieldName + "' />" + " <attribute name='createdon' />" + " <order attribute='new_name' descending='false' />" + " <filter type='and'>" + " <condition attribute='new_count' operator='eq' value='" + countval + "' />" + " <condition attribute='new_quarter' operator='eq' value='" + quarter + "' />" + " </filter>" + " </entity>" + "</fetch>"  
  7.     var Records = XrmServiceToolkit.Soap.Fetch(fetchXML);  
  8.     if (Records.length > 0) {  
  9.         var prevTotalValue = Records[0].attributes[TotalFieldName].value;  
  10.         var curTotalValue = prevTotalValue + FieldValue  
  11.         Xrm.Page.getAttribute(TotalFieldName).setValue(curTotalValue);  
  12.         return true;  
  13.     } else {  
  14.         Xrm.Page.getAttribute(TotalFieldName).setValue(FieldValue);  
  15.         return false;  
  16.     }  
  17. }   
To add the above JavaScript file to Web Resource in Microsoft Dynamics CRM, please follow the below steps.
Go to the top ribbon, select the Settings icon and from there, click on the "Solutions" to create a new custom solution.




To create new solution, provide the values to the yellow highlighted fields shown below.

Then, select Web Resources from the left navigation and upload the JavaScript file using New icon (yellow highlighted).




Click on the Form Editor of the Report form to configure how and when the JavaScript function should be called on change event of a field.

Now, select the field and Change Properties from the top ribbon.



Select the Events tab and include all the highlighted JavaScript files by clicking "Add" icon. The most important thing in Event Handlers section is to select the Event OnChange and map the TotalValues() from the TotalValueUpdate.js.



















































Now, go to the Events Handler section, click on the Add button to mention the JavaScript library name from the dropdown and to specify the function name. Then, click OK once you are done.












































Final output
Now, go to the entity form and check the value of Total values after entering this quarter value. It will be automatically adding the quarter value to the previous total and updating it to the current total value field.


I hope this article will be helpful for you to understand how to query Dynamics CRM Entities and update attributes in Form using JavaScript.

Wednesday, May 24, 2017

To read the XML using JavaScript (works in all browsers)

In this blog, I have explained the steps to read the XML using JavaScript. 

The below XML has Root "Tasks" and nodes "TaskName".

Input XML:
<?xml version="1.0" ?>
<Tasks>   
    <TaskName id="PromoteBestPractice">Promoted best practices</TaskName>
    <TaskName id="PromoteBeneEngage">Promoted beneficiary engagement and self-management</TaskName>
    <TaskName id="SustainPlan">Worked on a sustainability plan</TaskName>
</Tasks>


This JavaScript function accepts the xmlPath and xmlnodename as parameters. 

JavaScript:

function ChangeLabelTaskNameFrmXML(xmlPath,xmlnodename) {  
  
    var request = new XMLHttpRequest();
    request.open("GET", xmlPath, false);
    request.send();
    var xmldoc = request.responseXML; 
   //Extract the different values using a loop.     
    var xmlnode = xmldoc.getElementsByTagName(xmlnodename);

   // To read the xml nodes in XML file
    for (var i = 0; i < xmlnode.length; i++) {
        var lbltaskname = xmlnode[i].getAttribute('id');
        var newlbltaskname = xmlnode[i].textContent;
        alert ("Key:" + lbltaskname + "; Value: " + newlbltaskname );
   } 


Final Output will be displayed in message box with Key and Value as shown below.

Output:

Key: PromoteBestPractice; Value: Promoted best practices

Monday, May 22, 2017

Dynamics 365: To replace the labels in Entity Form using JavaScript


In this blog, have explained the steps for replacing the labels in Entity Form using JavaScript, XML and CSS files in Dynamics 365.

The total procedure contains 3 steps they are:

1.     XML file containing the label names to be replaced.

2.     Two JavaScript files are used here, one is for replacing the label and the other one to load the CSS dynamically.

3.     CSS file to change the styles of labels to wrap the text in the label.

XML Filename:

The most important things to be done in XML are naming root and nodes, id is the key to replace the label name. Field display name should be mentioned in id.

Tasks.XML

<?xml version="1.0" ?>

<Tasks>  

    <TaskName id="PnP">Promoted best practices, such as design, error handling and documentation. </TaskName>

    <TaskName id="Architecture">To build the process flow and infrastructure required for system. </TaskName>

    <TaskName id="SustainPlan">Worked on a sustainability plan</TaskName> 

</Tasks>

 Below JavaScript files will take care of the label text change.

JavaScript:

ReplaceLabels.js

function ChangeLabelTaskNameFrmXML() {  

   var xmlPath="../WebResources/new_Tasks.xml";

   //Put the <TaskName> element into an object. 

   var xmlnodePath = "//Tasks/TaskName";

   var xmldoc = new ActiveXObject("Microsoft.XMLDOM");

   xmldoc.preserveWhiteSpace = true;

   xmldoc.async = false;

   xmldoc.load(xmlPath);

   //Extract the different values using a loop.  

   var xmlnodelist;

   xmlnodelist= xmldoc.selectNodes(xmlnodePath);  

   for (var i = 0; i < xmlnodelist.length; i++) {

      var lbltaskname = xmlnodelist(i).getAttribute('id');

         var newlbltaskname =  xmlnodelist(i).text;

      ChangeLabelTaskName(lbltaskname, newlbltaskname);

   }

}



function ChangeLabelTaskName(lblTaskName, newlblTaskName)

{

  var lbl = "new_" + lblTaskName.toLowerCase();

  Xrm.Page.ui.controls.get(lbl).setLabel(newlblTaskName);  

}

Below JavaScript will load the CSS that contains the style for wrapping the text in label.

LoadCSS.js (for On-Premises and Online)

function LoadCSS(path) {

    var head = window.parent.document.getElementsByTagName('head')[0];

    var link = window.parent.document.createElement('link');

    link.rel = 'stylesheet';

    link.type = 'text/css';

    link.href = path;

    link.media = 'all';

    window.parent.document.head.appendChild(link);

}


 
Web Resources:
To Upload files (JavaScript, XML and CSS) to Web Resource.

While uploading files to Web Resource, you should provide few values like name, display name, file type and then upload file using browse button.


Form Properties:
After uploading files to Web Resources, you must select the Entity Form where the labels have to be replaced.

Now, go to Form Properties as shown above and add required JavaScript files as shown below. Once you have included the JavaScript files, you must map the functions from JavaScript and provide parameter values in Event Handlers section as shown in the below screenshots.

Please remember, we need to call these JavaScript functions on Form load (Control = Form, Event= OnLoad). That too CSS should be loaded first and then followed by replacing label text.

Here the function name is ChangeLabelTaskNameFrmXML and the parameters are provided as comma separated values.

Hope this article will help you to solve the issue in replacing form control labels with desired text.

Augmented Reality and Virtual Reality

Here is the quick overview of Augmented Reality and Virtual Reality, also have explained how it is being used today and how it can chan...