Sunday, 9 April 2017

New things on Dynamics 365 - Workflow Steps

Microsoft has totally revamped the Add Step button menu while writing a workflow. I haven't used most of the new functionality yet but here's some of the cool stuff.




Perform Action
Perform action gives you access to all the actions in the system. When I say all the actions - i mean all the actions (depending on your access privilige ofcourse) including the system ones, Like below I am running Qualify Lead action on a lead.






I suppose the other section that i marked in the Add Step menu are the custom workflows but I am not sure yet.

More on actions can be found in this link from msdn.

Thursday, 19 January 2017

New things on Dynamics 365



Prepare client customization has the bug fixed for Service Interaction. Check out this link from  MSDN

Customer Data type in Dynamics 365

Dynamics 365 has introduced a new data type for custom fields. its called Customer. When new field is created with this data type, the new field will act as parent customer id field in account/contact. Meaning there will be a look up created on the entity that can look up to both contact and account. Sweetness!!

Thursday, 25 September 2014

Jquery Ajax call example

function GetXrmElement() {
function CreateDebitTransaction() {                
                var Params = {
                    Leader : “Col. Hannibal Smith”,
                    Driver: “Cor. BA Baracus”,
                    Logistics: “Sgt Pedelton”,
                    pilot: “Lef Mardoc”
                };
                $.ajax({
                    type: "GET",
                    url: // ,
                    data: JSON.stringify(Params),                
                    data: Params,
                    contentType: "application/json; charset=utf-8",
                    dataType: "json",
                    success: function (result) {                        
                 // success method call back
                    },
                    error: function (xhr, ajaxOptions, thrownError) {
                        alert("Error Occured while executing the requese.");
                        return;
                    }
                });
            }




above is an asynchronous, non cross browser supported method. synchronous calls does not support jsonp. we can use async attribute but it has some limitations.

according to JQuery API documentation,


async (default: true)
Type: Boolean
By default, all requests are sent asynchronously (i.e. this is set to true by default). If you need synchronous requests, set this option to false. Cross-domain requests and dataType: "jsonp" requests do not support synchronous operation. Note that synchronous requests may temporarily lock the browser, disabling any actions while the request is active. As of jQuery 1.8, the use of async: false with jqXHR ($.Deferred) is deprecated; you must use the success/error/complete callback options instead of the corresponding methods of the jqXHR object such as jqXHR.done() or the deprecated jqXHR.success().

to make it look like sync call i normally put the continuation of the code in the success or error method. not the best work around but work around none the less.

for cross domain purposes some websites say using headers like below resolves the issue. although i have not tested it.

function GetXrmElement() {
headers: { 'Access-Control-Allow-Origin': '*' }
/* may work ??
beforeSend: function (request) {
       //request.setRequestHeader("Access-Control-Allow-Origin: ", "*")
},*/


Sunday, 21 September 2014

Passing Xrm Object from parent page(CRM) to child


Some times we need open a new window from CRM. This new window can be a window a that you open with a simple simple window.open() code. Or it can be a web resource that you want to open dynamically. Most of the time you need the Xrm object on that child page. I've written two small javascript function to pass Xrm object between parent and master page.

function GetXrmElement() {

                //to check if its an iframe
                var IframeCheck = isIframe();
                if (!IframeCheck) {
                    //support for CRM 4.0
                    if (window.opener != null && window.opener.Xrm != null) {
                        Xrm = window.opener.Xrm;
                    }
                        //CRM 2011 and upwords
                    else if (window.top != null && window.top.opener != null
                        && window.top.opener.parent != null && window.top.opener.parent.Xrm != null) {
                        Xrm = window.top.opener.parent.Xrm
                    }
                    else if (this.parent != null && this.parent.Xrm != null)
                        Xrm = this.parent.Xrm;

                    else if (window.top != null) {
                        Xrm = window.top.Xrm;
                    }


                    else {
                        Xrm = null;
                    }
                }

                else {
                    if (this.parent != null && this.parent.Xrm != null)
                        Xrm = this.parent.Xrm;
                    else if (document.parentWindow != null && document.parentWindow.parent != null && document.parentWindow.parent.Xrm != null)
                        Xrm = document.parentWindow.parent.Xrm;
                    else if (window.top != null)
                        Xrm = window.top.Xrm;
                    else
                        Xrm = null;
                }

                if (Xrm == null)
                    alert("Cannot retrieve Xrm object");
            }

Tuesday, 2 July 2013

CRM 2011: Deploying More Than One Steps using Developer toolkit

Part Two - The Final Steps

On my previous post I have discussed the steps for the preparation needed for creation of creating a plugin which can be used to handle multiple messages. This part will describe the final few steps needed to create the plug in.

For this you need to go to the RegisterFile.crmregister. Locate the tag “Step”. Copy the content of the tag and paste it right underneath the closing of the tag. Notice that it contains MessageName, Mode, PrimaryEntity, Stage and some other attributes. On the new step change attribute MessageName to “Update”. This is how you are telling the package project that you have added another step to the same plugin. The RegisterFile should look like following.


<?xml version="1.0"?>
<Register xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/crm/2011/tools/pluginregistration">
  <Solutions>
    <Solution Assembly="TestSolution.Plugins1.dll" Id="00000000-0000-0000-0000-000000000000" IsolationMode="Sandbox" SourceType="Database">
      <PluginTypes>
        <Plugin Description="Plug-in to InvoiceHandler" FriendlyName="InvoiceHandler" Name="TestSolution.Plugins1.InvoiceHandler" Id="00000000-0000-0000-0000-000000000000" TypeName="TestSolution.Plugins1.InvoiceHandler">
          <Steps>
            <clear />
            <Step CustomConfiguration="" Name="InvoiceHandler" Description="Post-Operation of Invoice Create" Id="00000000-0000-0000-0000-000000000000" MessageName="Create" Mode="Synchronous" PrimaryEntityName="invoice" Rank="1" SecureConfiguration="" Stage="PostOutsideTransaction" SupportedDeployment="ServerOnly">
              <Images />
            </Step>
            <Step CustomConfiguration="" Name="InvoiceHandler" Description="Post-Operation of Invoice Create" Id="00000000-0000-0000-0000-000000000000" MessageName="Update" Mode="Synchronous" PrimaryEntityName="invoice" Rank="1" SecureConfiguration="" Stage="PostOutsideTransaction" SupportedDeployment="ServerOnly">
              <Images />
            </Step>
          </Steps>
        </Plugin>
      </PluginTypes>
    </Solution>
  </Solutions>
  <XamlWorkflows />
</Register>




Open invoice handler and local the following line.


base.RegisteredEvents.Add(new Tuple<int, string, string, Action<LocalPluginContext>>(40, "Create", "invoice", new Action<LocalPluginContext>(ExecuteInvoiceHandler)));



Again copy and paste the line just underneath the original line. After that change second parameter to “Update”. Now the lines look like this.


base.RegisteredEvents.Add(new Tuple<int, string, string, Action<LocalPluginContext>>(40, "Create", "invoice", new Action<LocalPluginContext>(ExecuteInvoiceHandler)));

base.RegisteredEvents.Add(new Tuple<int, string, string, Action<LocalPluginContext>>(40, "Update", "invoice", new Action<LocalPluginContext>(ExecuteInvoiceHandler)));


That’s it. Just right click the package project and click deploy and the code will be deployed to the server. Finally after deployment the xml file should look like this,

<?xml version="1.0" encoding="utf-8"?>
<Register xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.microsoft.com/crm/2011/tools/pluginregistration">
  <Solutions>
    <Solution Assembly="TestSolution.Plugins1.dll" Id="6f5c9e09-58e3-e211-8a00-3c4a92dbdc39" IsolationMode="Sandbox" SourceType="Database">
      <PluginTypes>
        <Plugin Description="Plug-in to InvoiceHandler" FriendlyName="InvoiceHandler" Name="TestSolution.Plugins1.InvoiceHandler" Id="715c9e09-58e3-e211-8a00-3c4a92dbdc39" TypeName="TestSolution.Plugins1.InvoiceHandler">
          <Steps>
            <clear />
            <Step CustomConfiguration="" Name="InvoiceHandler" Description="Post-Operation of Invoice Create" Id="725c9e09-58e3-e211-8a00-3c4a92dbdc39" MessageName="Create" Mode="Synchronous" PrimaryEntityName="invoice" Rank="1" SecureConfiguration="" Stage="PostOutsideTransaction" SupportedDeployment="ServerOnly">
              <Images />
            </Step>
            <Step CustomConfiguration="" Name="InvoiceHandler" Description="Post-Operation of Invoice Create" Id="745c9e09-58e3-e211-8a00-3c4a92dbdc39" MessageName="Update" Mode="Synchronous" PrimaryEntityName="invoice" Rank="1" SecureConfiguration="" Stage="PostOutsideTransaction" SupportedDeployment="ServerOnly">
              <Images />
            </Step>
          </Steps>
        </Plugin>
      </PluginTypes>
    </Solution>
  </Solutions>
  <XamlWorkflows />
</Register>