Google Address Auto Complete for Dynamics 365 on Form Field


Google Address Auto Complete for CRM Form field

Download the HTML and CSS files from the GitHub (GoogleAddressAutoCompleteForDynamics365)

Get the API Key from Google Places and Replace “Google API KEY” with the API Key

API_Key

Edit the HTML for the CRM field you want the Address Auto Lookup. As CRM_Field_SchemaName_i and CRM_Field_SchemaName e.g. msdyn_addressname_i and msdyn_addressnameGoogleAddressHTMLCode

Add the HTML Web Resource on the CRM Form just below the Address Fields

GoogleAddressHTMLOnForm

Add Custom Parameter Data and Check the Visible by default

GoogleAddressHTMLGeneral

Go to Formatting Tab and edit number of rows to 1.

GoogleAddressHTMLFormatting

Add the following Code and call the function on Load of the Form. Change the Web Resource name of the CSS.

var addStylesForGoogleAddess = function () {

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

var link = window.parent.document.createElement(‘link’);

link.rel = ‘stylesheet’;

link.type = ‘text/css’;

link.href = “/WebResources/new_googleautocompletestyles“;

link.media = ‘all’;

head.appendChild(link);

};

 

Cheers!!!! 🙂

Posted in CRM, Dynamics 365, MS Dynamics 365, MS Dynamics CRM 2016 | Tagged , , , , , , , , , , , , | 2 Comments

Reading Excel and Creating the Records in CRM


Install the following Packages

excelReader_1

excelReader_2

Reference the DLLs

excelReader_3

Use the following Code:

var filePath = @”D:\CRM\records.xlsx”;

                using (var stream = File.Open(filePath, FileMode.Open, FileAccess.Read))

                {

                    // Auto-detect format, supports:

                    using (var reader = ExcelReaderFactory.CreateReader(stream))

                    {

                        do

                        {

                            while (reader.Read())

                            {

                                //0 row is Header

                                if (reader.Depth != 0)

                                {

                                    var recordId = reader[2];

                                    var teamName = reader[3];

                                }

                            }

                        } while (reader.NextResult());

                    }

                }

Reference: https://github.com/ExcelDataReader/ExcelDataReader

Thanks:

KD

Posted in CRM, Dynamics 365, MS Dynamics 365, MS Dynamics CRM 2015, MS Dynamics CRM 2016 | Tagged , , , , , , , , , | Leave a comment

Filter N:N Sub-Grid in Dynamics 365 without Custom Actions


Below code is for only N:N Relationship Sub-Grids. Copy the below code and register on OnLoad event of the Parent Entity Form on which the Sub-Grid exists.

Replace the <Sub-Grid Name>, <Form Lookup Field Name>, new_testingid, <Schema name of the Related Entity>.

//On Load of the Form

function onLoad() {

setTimeout(function () {

//get the element based on the <Sub-Grid Name>_addImageButton

var subGrid_ImageButton = window.parent.document.getElementById(“<Sub-Grid Name>_addImageButton”);

subGrid_ImageButton.addEventListener(“click”, function () {

//Get the Sub-Grid Control

var relatedEntity_SubGrid = Xrm.Page.getControl(‘<Sub-Grid Name>’);

//Get the Sub-Grid Lookup

var relatedEntity_SubGrid_Lookup = relatedEntity_SubGrid.$0_3.$1m_4.$O_4.$38_3.$3_6;

//Add the Pre-Search for Sub-Grid Lookup

relatedEntity_SubGrid_Lookup.addPreSearch(function () {

//Check whether the Lookup field on Form has value

if (Xrm.Page.getAttribute(“<Form Lookup Field Name>”).getValue()) {

//Get the ID of Lookup field on Form

var lookupIdOfLookupField = Xrm.Page.getAttribute(“<Form Lookup Field Name>”).getValue()[0].id;

//Build the Fetch Condition

var fetchCondition = “”;

fetchCondition += “<filter type=\”and\” >”;

fetchCondition += ” <condition attribute=\”new_testingid\” operator=\”eq\” value=\”” + lookupIdOfLookupField + “\” \/>”;

fetchCondition += ” <\/filter>”;

fetchCondition += “”;

relatedEntity_SubGrid_Lookup.addCustomFilter(fetchCondition, “<Schema name of the Related Entity>”);

}

})

})

}, 2000)

}

You are all set. 🙂

 

Cheers!!! 🙂

 

 

Posted in Dynamics 365, HTML, JavaScript, MS Dynamics 365, MS Dynamics CRM 2016 | Tagged , , , , , , , , , , , , , , , , , , , , , , , , | 2 Comments

Moving Default Solution from Dynamics CRM 2016 On-Premise to Dynamics CRM 2016 online Failure


If your Solution failing to import in Online environment due to following issue

31

Solution:

Unzip the Default Solution and edit the Solution.xml

Locate the following line and Remove it.

<RootComponent type=”61″ schemaName=”msdyn_LoadGuidedHelpISH.js” behavior=”0″ />

And find for the text “msdyn_LoadGuidedHelpISH.js” and Remove the following code.

<MissingDependency>

<Required key=”3″ type=”61″ schemaName=”msdyn_LoadGuidedHelpISH.js” displayName=”msdyn_LoadGuidedHelpISH.js” solution=”GuidedHelp (1.2.0.0)” />

<Dependent key=”3″ type=”61″ schemaName=”msdyn_LoadGuidedHelpISH.js” displayName=”msdyn_LoadGuidedHelpISH.js” />

</MissingDependency>

32

Zip all the files to Default Solution.

Cheers!!

Posted in CRM, Dynamics 365, MS Dynamics CRM 2016 | Tagged , , , , , , , , , , , , , , , , , , , | Leave a comment

Generate the Word Document in JavaScript using Word Templates


Pre-Requisites:

  1. Add XRMServiceToolKit Library (Click Here)
  2. Add Process Helper Library (Click Here)

Follow the Steps below.

//Fetch XML for Getting the ID of Document Template

var templateName = “Testing Template”;

var fetchXml = “<fetch version=’1.0′ output-format=’xml-platform’ mapping=’logical’ distinct=’false’>” +

“<entity name=’documenttemplate’>” +

“<attribute name=’documenttype’ />” +

“<attribute name=’name’ />” +

“<attribute name=’status’ />” +

“<attribute name=’modifiedon’ />” +

“<attribute name=’modifiedby’ />” +

“<attribute name=’description’ />” +

“<order attribute=’documenttype’ descending=’false’ />” +

“<order attribute=’name’ descending=’false’ />” +

“<filter type=’and’>” +

“<condition attribute=’documenttype’ operator=’eq’ value=’2′ />” +

“<condition attribute=’status’ operator=’eq’ value=’0′ />” +

“<condition attribute=’name’ operator=’eq’ value='” + templateName + “‘ />” +

“</filter>” +

“</entity>” +

“</fetch>”;

//Fetch the document template

var docTemplateResults = XrmServiceToolkit.Soap.Fetch(fetchXml);

//If Template found

if (docTemplateResults.length > 0) {

debugger;

//Get the template Id

var templateId = docTemplateResults[0].attributes.documenttemplateid.value;

// Call an Action

Process.callAction(“SetWordTemplate”,

[{

key: “Target”,

type: Process.Type.EntityReference,

value: new Process.EntityReference(“account”, Xrm.Page.data.entity.getId())

},

{

key: “SelectedTemplate”,

type: Process.Type.EntityReference,

value: new Process.EntityReference(“documenttemplate”, templateId)

}],

function (params) {

debugger;

// Success

alert(“Success” + params);

},

function (e, t) {

debugger;

// Error

alert(e);

// Write the trace log to the dev console

if (window.console && console.error) {

console.error(e + “\n” + t);

}

});

}

 

Posted in CRM, Dynamics 365, Java Script, JavaScript, Ms Dynamics CRM 2013, MS Dynamics CRM 2015, MS Dynamics CRM 2016 | Tagged , , , , , , , , , , , , , , , , , , , | Leave a comment

How to get Last Run of the Reports in Dynamics 365 On-Premise


Navigate to the CRM Organization Database – Right Click – Select “New Query”

Paste the following Query and replace the “ORG_MSCRM” with your Organization Database and “ReportServer_MSCRM” with your Report Server Database. Execute the Query.

with ReportNames as (

select rn.name, ‘{‘ + cast(rn.reportid as nvarchar(40)) + ‘}’ as reportid

from ORG_MSCRM..FilteredReport rn

)

SELECT

rn.Name as ‘Report Name’,

count(*) as ‘Report Run Count’,

MIN(e.TimeStart) as ‘First Run Time’,

max(E.TimeEnd) as ‘Last Run Time’

FROM ReportServer_MSCRM.dbo.Catalog Ca with(nolock)

left outer join ReportNames rn on Ca.Name = rn.ReportID

LEFT OUTER JOIN ReportServer_MSCRM.dbo.ExecutionLog  E with(nolock) ON Ca.ItemID = E.ReportID

WHERE Ca.type=2

and rn.Name is not null

group by rn.Name

order by ‘Report Run Count’ desc

 

 

http://www.sidesofmarch.com/index.php/archive/2015/04/06/which-ssrs-reports-are-being-run-through-dynamics-crm/

Posted in CRM, Dynamics 365, Ms Dynamics CRM 2013, MS Dynamics CRM 2015, MS Dynamics CRM 2016 | Tagged , , , , , , , , , , , , , , , , , , , , , | Leave a comment