Thursday, December 8, 2011

Add an Item To a Campaign Activity in Microsoft Dynamics CRM 2011 Using .NET or Jscript

This illustration shows how to add an item to a campaign activity in Microsoft Dynamics CRM 2011 with AddItemCampaignActivityRequest.  This example will be given in Jscript (SOAP) and in C# (.NET).
    Ok, here is what the code looks like!
    First in C#:

    AddItemCampaignActivityRequest req = new AddItemCampaignActivityRequest();
    req.CampaignActivityId = new Guid("9D817068-911C-E111-8423-1CC1DEF1B5FF");
    req.EntityName = List.EntityLogicalName;
    req.ItemId = new Guid("0F981108-F011-E111-8E08-1CC1DEF1353B");
    AddItemCampaignActivityResponse resp = (AddItemCampaignActivityResponse)service.Execute(req);
    
    

    If you need help instantiating a service object in .NET within a plugin check out this post:
    http://mileyja.blogspot.com/2011/04/instantiating-service-object-within.html

    Now here is the Jscript nicely formatted by the CRM 2011 SOAP formatter. Available at: http://crm2011soap.codeplex.com/

    Now in Jscript


    This example is asynchronous, if you want to learn how to make JScript SOAP calls synchronously please visit this post: http://mileyja.blogspot.com/2011/07/using-jscript-to-access-soap-web.html

    
    if (typeof (SDK) == "undefined")
       { SDK = { __namespace: true }; }
           //This will establish a more unique namespace for functions in this library. This will reduce the 
           // potential for functions to be overwritten due to a duplicate name when the library is loaded.
           SDK.SAMPLES = {
               _getServerUrl: function () {
                   ///<summary>
                   /// Returns the URL for the SOAP endpoint using the context information available in the form
                   /// or HTML Web resource.
                   ///</summary>
                   var OrgServicePath = "/XRMServices/2011/Organization.svc/web";
                   var serverUrl = "";
                   if (typeof GetGlobalContext == "function") {
                       var context = GetGlobalContext();
                       serverUrl = context.getServerUrl();
                   }
                   else {
                       if (typeof Xrm.Page.context == "object") {
                             serverUrl = Xrm.Page.context.getServerUrl();
                       }
                       else
                       { throw new Error("Unable to access the server URL"); }
                       }
                      if (serverUrl.match(/\/$/)) {
                           serverUrl = serverUrl.substring(0, serverUrl.length - 1);
                       } 
                       return serverUrl + OrgServicePath;
                   }, 
               AddItemCampaignActivityRequest: function () {
                   var requestMain = ""
                   requestMain += "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">";
                   requestMain += "  <s:Body>";
                   requestMain += "    <Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">";
                   requestMain += "      <request i:type=\"b:AddItemCampaignActivityRequest\" xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\" xmlns:b=\"http://schemas.microsoft.com/crm/2011/Contracts\">";
                   requestMain += "        <a:Parameters xmlns:c=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">";
                   requestMain += "          <a:KeyValuePairOfstringanyType>";
                   requestMain += "            <c:key>CampaignActivityId</c:key>";
                   requestMain += "            <c:value i:type=\"d:guid\" xmlns:d=\"http://schemas.microsoft.com/2003/10/Serialization/\">9d817068-911c-e111-8423-1cc1def1b5ff</c:value>";
                   requestMain += "          </a:KeyValuePairOfstringanyType>";
                   requestMain += "          <a:KeyValuePairOfstringanyType>";
                   requestMain += "            <c:key>ItemId</c:key>";
                   requestMain += "            <c:value i:type=\"d:guid\" xmlns:d=\"http://schemas.microsoft.com/2003/10/Serialization/\">0f981108-f011-e111-8e08-1cc1def1353b</c:value>";
                   requestMain += "          </a:KeyValuePairOfstringanyType>";
                   requestMain += "          <a:KeyValuePairOfstringanyType>";
                   requestMain += "            <c:key>EntityName</c:key>";
                   requestMain += "            <c:value i:type=\"d:string\" xmlns:d=\"http://www.w3.org/2001/XMLSchema\">list</c:value>";
                   requestMain += "          </a:KeyValuePairOfstringanyType>";
                   requestMain += "        </a:Parameters>";
                   requestMain += "        <a:RequestId i:nil=\"true\" />";
                   requestMain += "        <a:RequestName>AddItemCampaignActivity</a:RequestName>";
                   requestMain += "      </request>";
                   requestMain += "    </Execute>";
                   requestMain += "  </s:Body>";
                   requestMain += "</s:Envelope>";
                   var req = new XMLHttpRequest();
                   req.open("POST", SDK.SAMPLES._getServerUrl(), true)
                   // Responses will return XML. It isn't possible to return JSON.
                   req.setRequestHeader("Accept", "application/xml, text/xml, */*");
                   req.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
                   req.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute");
                   var successCallback = null;
                   var errorCallback = null;
                   req.onreadystatechange = function () { SDK.SAMPLES.AddItemCampaignActivityResponse(req, successCallback, errorCallback); };
                   req.send(requestMain);
               },
           AddItemCampaignActivityResponse: function (req, successCallback, errorCallback) {
                   ///<summary>
                   /// Recieves the assign response
                   ///</summary>
                   ///<param name="req" Type="XMLHttpRequest">
                   /// The XMLHttpRequest response
                   ///</param>
                   ///<param name="successCallback" Type="Function">
                   /// The function to perform when an successfult response is returned.
                   /// For this message no data is returned so a success callback is not really necessary.
                   ///</param>
                   ///<param name="errorCallback" Type="Function">
                   /// The function to perform when an error is returned.
                   /// This function accepts a JScript error returned by the _getError function
                   ///</param>
                   if (req.readyState == 4) {
                   if (req.status == 200) {
                   if (successCallback != null)
                   { successCallback(); }
                   }
                   else {
                       errorCallback(SDK.SAMPLES._getError(req.responseXML));
                   }
               }
           },
           _getError: function (faultXml) {
               ///<summary>
               /// Parses the WCF fault returned in the event of an error.
               ///</summary>
               ///<param name="faultXml" Type="XML">
               /// The responseXML property of the XMLHttpRequest response.
               ///</param>
               var errorMessage = "Unknown Error (Unable to parse the fault)";
               if (typeof faultXml == "object") {
                   try {
                       var bodyNode = faultXml.firstChild.firstChild;
                       //Retrieve the fault node
                       for (var i = 0; i < bodyNode.childNodes.length; i++) {
                           var node = bodyNode.childNodes[i];
                           //NOTE: This comparison does not handle the case where the XML namespace changes
                           if ("s:Fault" == node.nodeName) {
                           for (var j = 0; j < node.childNodes.length; j++) {
                               var faultStringNode = node.childNodes[j];
                               if ("faultstring" == faultStringNode.nodeName) {
                                   errorMessage = faultStringNode.text;
                                   break;
                               }
                           }
                           break;
                       }
                   }
               }
               catch (e) { };
            }
            return new Error(errorMessage);
         },
     __namespace: true
    };
    
    


    To understand how to parse the response please review my post on using the DOM parser.
    Now you can call the SDK.SAMPLES.AddItemCampaignActivityRequest function from your form jscript handler.


    Thats all there is to it!
    -

    Wednesday, December 7, 2011

    Copy a Campaign Response in Microsoft Dynamics CRM 2011 Using .NET or Jscript

    This illustration shows how to copy a campaign response in Microsoft Dynamics CRM 2011 with CopyCampaignResponseRequest.  This example will be given in Jscript (SOAP) and in C# (.NET).
      Ok, here is what the code looks like!
      First in C#:

      CopyCampaignResponseRequest req = new CopyCampaignResponseRequest();
      req.CampaignResponseId = new EntityReference(CampaignResponse.EntityLogicalName, new Guid("4834BAEE-E820-E111-8E08-1CC1DEF1353B"));
      CopyCampaignResponseResponse resp = (CopyCampaignResponseResponse)service.Execute(req);
      
      

      If you need help instantiating a service object in .NET within a plugin check out this post:
      http://mileyja.blogspot.com/2011/04/instantiating-service-object-within.html

      Now here is the Jscript nicely formatted by the CRM 2011 SOAP formatter. Available at: http://crm2011soap.codeplex.com/

      Now in Jscript


      This example is asynchronous, if you want to learn how to make JScript SOAP calls synchronously please visit this post: http://mileyja.blogspot.com/2011/07/using-jscript-to-access-soap-web.html

      
      if (typeof (SDK) == "undefined")
         { SDK = { __namespace: true }; }
             //This will establish a more unique namespace for functions in this library. This will reduce the 
             // potential for functions to be overwritten due to a duplicate name when the library is loaded.
             SDK.SAMPLES = {
                 _getServerUrl: function () {
                     ///<summary>
                     /// Returns the URL for the SOAP endpoint using the context information available in the form
                     /// or HTML Web resource.
                     ///</summary>
                     var OrgServicePath = "/XRMServices/2011/Organization.svc/web";
                     var serverUrl = "";
                     if (typeof GetGlobalContext == "function") {
                         var context = GetGlobalContext();
                         serverUrl = context.getServerUrl();
                     }
                     else {
                         if (typeof Xrm.Page.context == "object") {
                               serverUrl = Xrm.Page.context.getServerUrl();
                         }
                         else
                         { throw new Error("Unable to access the server URL"); }
                         }
                        if (serverUrl.match(/\/$/)) {
                             serverUrl = serverUrl.substring(0, serverUrl.length - 1);
                         } 
                         return serverUrl + OrgServicePath;
                     }, 
                 CopyCampaignResponseRequest: function () {
                     var requestMain = ""
                     requestMain += "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">";
                     requestMain += "  <s:Body>";
                     requestMain += "    <Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">";
                     requestMain += "      <request i:type=\"b:CopyCampaignResponseRequest\" xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\" xmlns:b=\"http://schemas.microsoft.com/crm/2011/Contracts\">";
                     requestMain += "        <a:Parameters xmlns:c=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">";
                     requestMain += "          <a:KeyValuePairOfstringanyType>";
                     requestMain += "            <c:key>CampaignResponseId</c:key>";
                     requestMain += "            <c:value i:type=\"a:EntityReference\">";
                     requestMain += "              <a:Id>4834baee-e820-e111-8e08-1cc1def1353b</a:Id>";
                     requestMain += "              <a:LogicalName>campaignresponse</a:LogicalName>";
                     requestMain += "              <a:Name i:nil=\"true\" />";
                     requestMain += "            </c:value>";
                     requestMain += "          </a:KeyValuePairOfstringanyType>";
                     requestMain += "        </a:Parameters>";
                     requestMain += "        <a:RequestId i:nil=\"true\" />";
                     requestMain += "        <a:RequestName>CopyCampaignResponse</a:RequestName>";
                     requestMain += "      </request>";
                     requestMain += "    </Execute>";
                     requestMain += "  </s:Body>";
                     requestMain += "</s:Envelope>";
                     var req = new XMLHttpRequest();
                     req.open("POST", SDK.SAMPLES._getServerUrl(), true)
                     // Responses will return XML. It isn't possible to return JSON.
                     req.setRequestHeader("Accept", "application/xml, text/xml, */*");
                     req.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
                     req.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute");
                     var successCallback = null;
                     var errorCallback = null;
                     req.onreadystatechange = function () { SDK.SAMPLES.CopyCampaignResponseResponse(req, successCallback, errorCallback); };
                     req.send(requestMain);
                 },
             CopyCampaignResponseResponse: function (req, successCallback, errorCallback) {
                     ///<summary>
                     /// Recieves the assign response
                     ///</summary>
                     ///<param name="req" Type="XMLHttpRequest">
                     /// The XMLHttpRequest response
                     ///</param>
                     ///<param name="successCallback" Type="Function">
                     /// The function to perform when an successfult response is returned.
                     /// For this message no data is returned so a success callback is not really necessary.
                     ///</param>
                     ///<param name="errorCallback" Type="Function">
                     /// The function to perform when an error is returned.
                     /// This function accepts a JScript error returned by the _getError function
                     ///</param>
                     if (req.readyState == 4) {
                     if (req.status == 200) {
                     if (successCallback != null)
                     { successCallback(); }
                     }
                     else {
                         errorCallback(SDK.SAMPLES._getError(req.responseXML));
                     }
                 }
             },
             _getError: function (faultXml) {
                 ///<summary>
                 /// Parses the WCF fault returned in the event of an error.
                 ///</summary>
                 ///<param name="faultXml" Type="XML">
                 /// The responseXML property of the XMLHttpRequest response.
                 ///</param>
                 var errorMessage = "Unknown Error (Unable to parse the fault)";
                 if (typeof faultXml == "object") {
                     try {
                         var bodyNode = faultXml.firstChild.firstChild;
                         //Retrieve the fault node
                         for (var i = 0; i < bodyNode.childNodes.length; i++) {
                             var node = bodyNode.childNodes[i];
                             //NOTE: This comparison does not handle the case where the XML namespace changes
                             if ("s:Fault" == node.nodeName) {
                             for (var j = 0; j < node.childNodes.length; j++) {
                                 var faultStringNode = node.childNodes[j];
                                 if ("faultstring" == faultStringNode.nodeName) {
                                     errorMessage = faultStringNode.text;
                                     break;
                                 }
                             }
                             break;
                         }
                     }
                 }
                 catch (e) { };
              }
              return new Error(errorMessage);
           },
       __namespace: true
      };
      
      


      To understand how to parse the response please review my post on using the DOM parser.
      Now you can call the SDK.SAMPLES.CopyCampaignResponseRequest function from your form jscript handler.


      Thats all there is to it!
      -

      Tuesday, December 6, 2011

      Add an Item To a Campaign in Microsoft Dynamics CRM 2011 Using .NET or Jscript

      This illustration shows how to add an item to a campaign in Microsoft Dynamics CRM 2011 with AddItemCampaignRequest.  This example will be given in Jscript (SOAP) and in C# (.NET).

      Important Note:  Entity added to campaign using the AddItemCampaignRequest must be of one of the following types

      • Campaign
      • List
      • Product
      • SalesLiterature

        Ok, here is what the code looks like!
        First in C#:

        AddItemCampaignRequest req = new AddItemCampaignRequest();
        req.CampaignId = new Guid("15C65044-541C-E111-8E08-1CC1DEF1353B");
        req.EntityName = Product.EntityLogicalName;
        req.EntityId = new Guid("6FBC3543-1515-E111-8E08-1CC1DEF1353B");
        
        AddItemCampaignResponse resp = (AddItemCampaignResponse)service.Execute(req);
        
        

        If you need help instantiating a service object in .NET within a plugin check out this post:
        http://mileyja.blogspot.com/2011/04/instantiating-service-object-within.html

        Now here is the Jscript nicely formatted by the CRM 2011 SOAP formatter. Available at: http://crm2011soap.codeplex.com/

        Now in Jscript


        This example is asynchronous, if you want to learn how to make JScript SOAP calls synchronously please visit this post: http://mileyja.blogspot.com/2011/07/using-jscript-to-access-soap-web.html

        
        if (typeof (SDK) == "undefined")
           { SDK = { __namespace: true }; }
               //This will establish a more unique namespace for functions in this library. This will reduce the 
               // potential for functions to be overwritten due to a duplicate name when the library is loaded.
               SDK.SAMPLES = {
                   _getServerUrl: function () {
                       ///<summary>
                       /// Returns the URL for the SOAP endpoint using the context information available in the form
                       /// or HTML Web resource.
                       ///</summary>
                       var OrgServicePath = "/XRMServices/2011/Organization.svc/web";
                       var serverUrl = "";
                       if (typeof GetGlobalContext == "function") {
                           var context = GetGlobalContext();
                           serverUrl = context.getServerUrl();
                       }
                       else {
                           if (typeof Xrm.Page.context == "object") {
                                 serverUrl = Xrm.Page.context.getServerUrl();
                           }
                           else
                           { throw new Error("Unable to access the server URL"); }
                           }
                          if (serverUrl.match(/\/$/)) {
                               serverUrl = serverUrl.substring(0, serverUrl.length - 1);
                           } 
                           return serverUrl + OrgServicePath;
                       }, 
                   AddItemCampaignRequest: function () {
                       var requestMain = ""
                       requestMain += "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">";
                       requestMain += "  <s:Body>";
                       requestMain += "    <Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">";
                       requestMain += "      <request i:type=\"b:AddItemCampaignRequest\" xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\" xmlns:b=\"http://schemas.microsoft.com/crm/2011/Contracts\">";
                       requestMain += "        <a:Parameters xmlns:c=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">";
                       requestMain += "          <a:KeyValuePairOfstringanyType>";
                       requestMain += "            <c:key>CampaignId</c:key>";
                       requestMain += "            <c:value i:type=\"d:guid\" xmlns:d=\"http://schemas.microsoft.com/2003/10/Serialization/\">15c65044-541c-e111-8e08-1cc1def1353b</c:value>";
                       requestMain += "          </a:KeyValuePairOfstringanyType>";
                       requestMain += "          <a:KeyValuePairOfstringanyType>";
                       requestMain += "            <c:key>EntityId</c:key>";
                       requestMain += "            <c:value i:type=\"d:guid\" xmlns:d=\"http://schemas.microsoft.com/2003/10/Serialization/\">6fbc3543-1515-e111-8e08-1cc1def1353b</c:value>";
                       requestMain += "          </a:KeyValuePairOfstringanyType>";
                       requestMain += "          <a:KeyValuePairOfstringanyType>";
                       requestMain += "            <c:key>EntityName</c:key>";
                       requestMain += "            <c:value i:type=\"d:string\" xmlns:d=\"http://www.w3.org/2001/XMLSchema\">product</c:value>";
                       requestMain += "          </a:KeyValuePairOfstringanyType>";
                       requestMain += "        </a:Parameters>";
                       requestMain += "        <a:RequestId i:nil=\"true\" />";
                       requestMain += "        <a:RequestName>AddItemCampaign</a:RequestName>";
                       requestMain += "      </request>";
                       requestMain += "    </Execute>";
                       requestMain += "  </s:Body>";
                       requestMain += "</s:Envelope>";
                       var req = new XMLHttpRequest();
                       req.open("POST", SDK.SAMPLES._getServerUrl(), true)
                       // Responses will return XML. It isn't possible to return JSON.
                       req.setRequestHeader("Accept", "application/xml, text/xml, */*");
                       req.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
                       req.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute");
                       var successCallback = null;
                       var errorCallback = null;
                       req.onreadystatechange = function () { SDK.SAMPLES.AddItemCampaignResponse(req, successCallback, errorCallback); };
                       req.send(requestMain);
                   },
               AddItemCampaignResponse: function (req, successCallback, errorCallback) {
                       ///<summary>
                       /// Recieves the assign response
                       ///</summary>
                       ///<param name="req" Type="XMLHttpRequest">
                       /// The XMLHttpRequest response
                       ///</param>
                       ///<param name="successCallback" Type="Function">
                       /// The function to perform when an successfult response is returned.
                       /// For this message no data is returned so a success callback is not really necessary.
                       ///</param>
                       ///<param name="errorCallback" Type="Function">
                       /// The function to perform when an error is returned.
                       /// This function accepts a JScript error returned by the _getError function
                       ///</param>
                       if (req.readyState == 4) {
                       if (req.status == 200) {
                       if (successCallback != null)
                       { successCallback(); }
                       }
                       else {
                           errorCallback(SDK.SAMPLES._getError(req.responseXML));
                       }
                   }
               },
               _getError: function (faultXml) {
                   ///<summary>
                   /// Parses the WCF fault returned in the event of an error.
                   ///</summary>
                   ///<param name="faultXml" Type="XML">
                   /// The responseXML property of the XMLHttpRequest response.
                   ///</param>
                   var errorMessage = "Unknown Error (Unable to parse the fault)";
                   if (typeof faultXml == "object") {
                       try {
                           var bodyNode = faultXml.firstChild.firstChild;
                           //Retrieve the fault node
                           for (var i = 0; i < bodyNode.childNodes.length; i++) {
                               var node = bodyNode.childNodes[i];
                               //NOTE: This comparison does not handle the case where the XML namespace changes
                               if ("s:Fault" == node.nodeName) {
                               for (var j = 0; j < node.childNodes.length; j++) {
                                   var faultStringNode = node.childNodes[j];
                                   if ("faultstring" == faultStringNode.nodeName) {
                                       errorMessage = faultStringNode.text;
                                       break;
                                   }
                               }
                               break;
                           }
                       }
                   }
                   catch (e) { };
                }
                return new Error(errorMessage);
             },
         __namespace: true
        };
        
        


        To understand how to parse the response please review my post on using the DOM parser.
        Now you can call the SDK.SAMPLES.AddItemCampaignRequest function from your form jscript handler.


        Thats all there is to it!
        -

        Monday, December 5, 2011

        Publish a Duplicate Detection Rule in Microsoft Dynamics CRM 2011 Using .NET or Jscript

        This illustration shows how publish a duplicate detection rule in Microsoft Dynamics CRM 2011 with PublishDuplicateRuleRequest.  This example will be given in Jscript (SOAP) and in C# (.NET).
          Ok, here is what the code looks like!
          First in C#:

          PublishDuplicateRuleRequest req = new PublishDuplicateRuleRequest();
          req.DuplicateRuleId = new Guid("D8D2E6CC-3A9B-48F8-A0C6-B9A1F10B9FB4");
          PublishDuplicateRuleResponse resp = (PublishDuplicateRuleResponse)service.Execute(req);
          
          

          If you need help instantiating a service object in .NET within a plugin check out this post:
          http://mileyja.blogspot.com/2011/04/instantiating-service-object-within.html

          Now here is the Jscript nicely formatted by the CRM 2011 SOAP formatter. Available at: http://crm2011soap.codeplex.com/

          Now in Jscript


          This example is asynchronous, if you want to learn how to make JScript SOAP calls synchronously please visit this post: http://mileyja.blogspot.com/2011/07/using-jscript-to-access-soap-web.html

          
          if (typeof (SDK) == "undefined")
             { SDK = { __namespace: true }; }
                 //This will establish a more unique namespace for functions in this library. This will reduce the 
                 // potential for functions to be overwritten due to a duplicate name when the library is loaded.
                 SDK.SAMPLES = {
                     _getServerUrl: function () {
                         ///<summary>
                         /// Returns the URL for the SOAP endpoint using the context information available in the form
                         /// or HTML Web resource.
                         ///</summary>
                         var OrgServicePath = "/XRMServices/2011/Organization.svc/web";
                         var serverUrl = "";
                         if (typeof GetGlobalContext == "function") {
                             var context = GetGlobalContext();
                             serverUrl = context.getServerUrl();
                         }
                         else {
                             if (typeof Xrm.Page.context == "object") {
                                   serverUrl = Xrm.Page.context.getServerUrl();
                             }
                             else
                             { throw new Error("Unable to access the server URL"); }
                             }
                            if (serverUrl.match(/\/$/)) {
                                 serverUrl = serverUrl.substring(0, serverUrl.length - 1);
                             } 
                             return serverUrl + OrgServicePath;
                         }, 
                     PublishDuplicateRuleRequest: function () {
                         var requestMain = ""
                         requestMain += "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">";
                         requestMain += "  <s:Body>";
                         requestMain += "    <Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">";
                         requestMain += "      <request i:type=\"b:PublishDuplicateRuleRequest\" xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\" xmlns:b=\"http://schemas.microsoft.com/crm/2011/Contracts\">";
                         requestMain += "        <a:Parameters xmlns:c=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">";
                         requestMain += "          <a:KeyValuePairOfstringanyType>";
                         requestMain += "            <c:key>DuplicateRuleId</c:key>";
                         requestMain += "            <c:value i:type=\"d:guid\" xmlns:d=\"http://schemas.microsoft.com/2003/10/Serialization/\">d8d2e6cc-3a9b-48f8-a0c6-b9a1f10b9fb4</c:value>";
                         requestMain += "          </a:KeyValuePairOfstringanyType>";
                         requestMain += "        </a:Parameters>";
                         requestMain += "        <a:RequestId i:nil=\"true\" />";
                         requestMain += "        <a:RequestName>PublishDuplicateRule</a:RequestName>";
                         requestMain += "      </request>";
                         requestMain += "    </Execute>";
                         requestMain += "  </s:Body>";
                         requestMain += "</s:Envelope>";
                         var req = new XMLHttpRequest();
                         req.open("POST", SDK.SAMPLES._getServerUrl(), true)
                         // Responses will return XML. It isn't possible to return JSON.
                         req.setRequestHeader("Accept", "application/xml, text/xml, */*");
                         req.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
                         req.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute");
                         var successCallback = null;
                         var errorCallback = null;
                         req.onreadystatechange = function () { SDK.SAMPLES.PublishDuplicateRuleResponse(req, successCallback, errorCallback); };
                         req.send(requestMain);
                     },
                 PublishDuplicateRuleResponse: function (req, successCallback, errorCallback) {
                         ///<summary>
                         /// Recieves the assign response
                         ///</summary>
                         ///<param name="req" Type="XMLHttpRequest">
                         /// The XMLHttpRequest response
                         ///</param>
                         ///<param name="successCallback" Type="Function">
                         /// The function to perform when an successfult response is returned.
                         /// For this message no data is returned so a success callback is not really necessary.
                         ///</param>
                         ///<param name="errorCallback" Type="Function">
                         /// The function to perform when an error is returned.
                         /// This function accepts a JScript error returned by the _getError function
                         ///</param>
                         if (req.readyState == 4) {
                         if (req.status == 200) {
                         if (successCallback != null)
                         { successCallback(); }
                         }
                         else {
                             errorCallback(SDK.SAMPLES._getError(req.responseXML));
                         }
                     }
                 },
                 _getError: function (faultXml) {
                     ///<summary>
                     /// Parses the WCF fault returned in the event of an error.
                     ///</summary>
                     ///<param name="faultXml" Type="XML">
                     /// The responseXML property of the XMLHttpRequest response.
                     ///</param>
                     var errorMessage = "Unknown Error (Unable to parse the fault)";
                     if (typeof faultXml == "object") {
                         try {
                             var bodyNode = faultXml.firstChild.firstChild;
                             //Retrieve the fault node
                             for (var i = 0; i < bodyNode.childNodes.length; i++) {
                                 var node = bodyNode.childNodes[i];
                                 //NOTE: This comparison does not handle the case where the XML namespace changes
                                 if ("s:Fault" == node.nodeName) {
                                 for (var j = 0; j < node.childNodes.length; j++) {
                                     var faultStringNode = node.childNodes[j];
                                     if ("faultstring" == faultStringNode.nodeName) {
                                         errorMessage = faultStringNode.text;
                                         break;
                                     }
                                 }
                                 break;
                             }
                         }
                     }
                     catch (e) { };
                  }
                  return new Error(errorMessage);
               },
           __namespace: true
          };
          
          


          To understand how to parse the response please review my post on using the DOM parser.
          Now you can call the SDK.SAMPLES.PublishDuplicateRuleRequest function from your form jscript handler.


          Thats all there is to it!
          -

          Thursday, December 1, 2011

          Unpublish a Duplicate Detection Rule in Microsoft Dynamics CRM 2011 Using .NET or Jscript

          This illustration shows how unpublish a duplicate detection rule in Microsoft Dynamics CRM 2011 with UnpublishDuplicateRuleRequest.  This example will be given in Jscript (SOAP) and in C# (.NET).
            Ok, here is what the code looks like!
            First in C#:

            UnpublishDuplicateRuleRequest req = new UnpublishDuplicateRuleRequest();
            req.DuplicateRuleId = new Guid("D8D2E6CC-3A9B-48F8-A0C6-B9A1F10B9FB4");
            UnpublishDuplicateRuleResponse resp = (UnpublishDuplicateRuleResponse)slos.Execute(req);
            
            

            If you need help instantiating a service object in .NET within a plugin check out this post:
            http://mileyja.blogspot.com/2011/04/instantiating-service-object-within.html

            Now here is the Jscript nicely formatted by the CRM 2011 SOAP formatter. Available at: http://crm2011soap.codeplex.com/

            Now in Jscript


            This example is asynchronous, if you want to learn how to make JScript SOAP calls synchronously please visit this post: http://mileyja.blogspot.com/2011/07/using-jscript-to-access-soap-web.html

            if (typeof (SDK) == "undefined")
               { SDK = { __namespace: true }; }
                   //This will establish a more unique namespace for functions in this library. This will reduce the 
                   // potential for functions to be overwritten due to a duplicate name when the library is loaded.
                   SDK.SAMPLES = {
                       _getServerUrl: function () {
                           ///<summary>
                           /// Returns the URL for the SOAP endpoint using the context information available in the form
                           /// or HTML Web resource.
                           ///</summary>
                           var ServicePath = "/XRMServices/2011/Organization.svc/web";
                           var serverUrl = "";
                           if (typeof GetGlobalContext == "function") {
                               var context = GetGlobalContext();
                               serverUrl = context.getServerUrl();
                           }
                           else {
                               if (typeof Xrm.Page.context == "object") {
                                     serverUrl = Xrm.Page.context.getServerUrl();
                               }
                               else
                               { throw new Error("Unable to access the server URL"); }
                               }
                              if (serverUrl.match(/\/$/)) {
                                   serverUrl = serverUrl.substring(0, serverUrl.length - 1);
                               } 
                               return serverUrl + ServicePath;
                           }, 
                       UnpublishDuplicateRuleRequest: function () {
                           var requestMain = ""
                           requestMain += "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">";
                           requestMain += "  <s:Body>";
                           requestMain += "    <Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">";
                           requestMain += "      <request i:type=\"b:UnpublishDuplicateRuleRequest\" xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\" xmlns:b=\"http://schemas.microsoft.com/crm/2011/Contracts\">";
                           requestMain += "        <a:Parameters xmlns:c=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">";
                           requestMain += "          <a:KeyValuePairOfstringanyType>";
                           requestMain += "            <c:key>DuplicateRuleId</c:key>";
                           requestMain += "            <c:value i:type=\"d:guid\" xmlns:d=\"http://schemas.microsoft.com/2003/10/Serialization/\">d8d2e6cc-3a9b-48f8-a0c6-b9a1f10b9fb4</c:value>";
                           requestMain += "          </a:KeyValuePairOfstringanyType>";
                           requestMain += "        </a:Parameters>";
                           requestMain += "        <a:RequestId i:nil=\"true\" />";
                           requestMain += "        <a:RequestName>UnpublishDuplicateRule</a:RequestName>";
                           requestMain += "      </request>";
                           requestMain += "    </Execute>";
                           requestMain += "  </s:Body>";
                           requestMain += "</s:Envelope>";
                           var req = new XMLHttpRequest();
                           req.open("POST", SDK.SAMPLES._getServerUrl(), true)
                           req.setRequestHeader("Accept", "application/xml, text/xml, */*");
                           req.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
                           req.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute");
                           var successCallback = null;
                           var errorCallback = null;
                           req.onreadystatechange = function () { SDK.SAMPLES.UnpublishDuplicateRuleResponse(req, successCallback, errorCallback); };
                           req.send(requestMain);
                       },
                   UnpublishDuplicateRuleResponse: function (req, successCallback, errorCallback) {
                           ///<summary>
                           /// Recieves the assign response
                           ///</summary>
                           ///<param name="req" Type="XMLHttpRequest">
                           /// The XMLHttpRequest response
                           ///</param>
                           ///<param name="successCallback" Type="Function">
                           /// The function to perform when an successfult response is returned.
                           /// For this message no data is returned so a success callback is not really necessary.
                           ///</param>
                           ///<param name="errorCallback" Type="Function">
                           /// The function to perform when an error is returned.
                           /// This function accepts a JScript error returned by the _getError function
                           ///</param>
                           if (req.readyState == 4) {
                           if (req.status == 200) {
                           if (successCallback != null)
                           { successCallback(); }
                           }
                           else {
                               errorCallback(SDK.SAMPLES._getError(req.responseXML));
                           }
                       }
                   },
                   _getError: function (faultXml) {
                       ///<summary>
                       /// Parses the WCF fault returned in the event of an error.
                       ///</summary>
                       ///<param name="faultXml" Type="XML">
                       /// The responseXML property of the XMLHttpRequest response.
                       ///</param>
                       var errorMessage = "Unknown Error (Unable to parse the fault)";
                       if (typeof faultXml == "object") {
                           try {
                               var bodyNode = faultXml.firstChild.firstChild;
                               //Retrieve the fault node
                               for (var i = 0; i < bodyNode.childNodes.length; i++) {
                                   var node = bodyNode.childNodes[i];
                                   //NOTE: This comparison does not handle the case where the XML namespace changes
                                   if ("s:Fault" == node.nodeName) {
                                   for (var j = 0; j < node.childNodes.length; j++) {
                                       var faultStringNode = node.childNodes[j];
                                       if ("faultstring" == faultStringNode.nodeName) {
                                           errorMessage = faultStringNode.text;
                                           break;
                                       }
                                   }
                                   break;
                               }
                           }
                       }
                       catch (e) { };
                    }
                    return new Error(errorMessage);
                 },
             __namespace: true
            };
            
            


            To understand how to parse the response please review my post on using the DOM parser.
            Now you can call the SDK.SAMPLES.UnpublishDuplicateRuleRequest function from your form jscript handler.


            Thats all there is to it!
            -

            Remove an Item From a Marketing Campaign in Microsoft Dynamics CRM 2011 Using .NET or Jscript

            This illustration shows how to remove an item from a marketing campaign in Microsoft Dynamics CRM 2011 with RemoveItemCampaignRequest.  This example will be given in Jscript (SOAP) and in C# (.NET).

            NOTE:  I do not like now the EntityId property of this request only asks for a GUID as it appears it could be a campaign activity, response, or any other type of entity attached to a marketing campaign.  This property should have been represented by an EntityReference object.
              Ok, here is what the code looks like!
              First in C#:

              RemoveItemCampaignRequest req = new RemoveItemCampaignRequest();
              // marketing campaign to remove an item from
              req.CampaignId = new Guid("15C65044-541C-E111-8E08-1CC1DEF1353B");
              //Guid for EntityID must represent an item attached to a campaign, in my case, I chose a target product
              req.EntityId = new Guid("6FBC3543-1515-E111-8E08-1CC1DEF1353B");
              RemoveItemCampaignResponse resp = (RemoveItemCampaignResponse)service.Execute(req);
              
              

              If you need help instantiating a service object in .NET within a plugin check out this post:
              http://mileyja.blogspot.com/2011/04/instantiating-service-object-within.html

              Now here is the Jscript nicely formatted by the CRM 2011 SOAP formatter. Available at: http://crm2011soap.codeplex.com/

              Now in Jscript


              This example is asynchronous, if you want to learn how to make JScript SOAP calls synchronously please visit this post: http://mileyja.blogspot.com/2011/07/using-jscript-to-access-soap-web.html

              
              if (typeof (SDK) == "undefined")
                 { SDK = { __namespace: true }; }
                     //This will establish a more unique namespace for functions in this library. This will reduce the 
                     // potential for functions to be overwritten due to a duplicate name when the library is loaded.
                     SDK.SAMPLES = {
                         _getServerUrl: function () {
                             ///<summary>
                             /// Returns the URL for the SOAP endpoint using the context information available in the form
                             /// or HTML Web resource.
                             ///</summary>
                             var OrgServicePath = "/XRMServices/2011/Organization.svc/web";
                             var serverUrl = "";
                             if (typeof GetGlobalContext == "function") {
                                 var context = GetGlobalContext();
                                 serverUrl = context.getServerUrl();
                             }
                             else {
                                 if (typeof Xrm.Page.context == "object") {
                                       serverUrl = Xrm.Page.context.getServerUrl();
                                 }
                                 else
                                 { throw new Error("Unable to access the server URL"); }
                                 }
                                if (serverUrl.match(/\/$/)) {
                                     serverUrl = serverUrl.substring(0, serverUrl.length - 1);
                                 } 
                                 return serverUrl + OrgServicePath;
                             }, 
                         RemoveItemCampaignRequest: function () {
                             var requestMain = ""
                             requestMain += "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">";
                             requestMain += "  <s:Body>";
                             requestMain += "    <Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">";
                             requestMain += "      <request i:type=\"b:RemoveItemCampaignRequest\" xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\" xmlns:b=\"http://schemas.microsoft.com/crm/2011/Contracts\">";
                             requestMain += "        <a:Parameters xmlns:c=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">";
                             requestMain += "          <a:KeyValuePairOfstringanyType>";
                             requestMain += "            <c:key>CampaignId</c:key>";
                             requestMain += "            <c:value i:type=\"d:guid\" xmlns:d=\"http://schemas.microsoft.com/2003/10/Serialization/\">15c65044-541c-e111-8e08-1cc1def1353b</c:value>";
                             requestMain += "          </a:KeyValuePairOfstringanyType>";
                             requestMain += "          <a:KeyValuePairOfstringanyType>";
                             requestMain += "            <c:key>EntityId</c:key>";
                             requestMain += "            <c:value i:type=\"d:guid\" xmlns:d=\"http://schemas.microsoft.com/2003/10/Serialization/\">6fbc3543-1515-e111-8e08-1cc1def1353b</c:value>";
                             requestMain += "          </a:KeyValuePairOfstringanyType>";
                             requestMain += "        </a:Parameters>";
                             requestMain += "        <a:RequestId i:nil=\"true\" />";
                             requestMain += "        <a:RequestName>RemoveItemCampaign</a:RequestName>";
                             requestMain += "      </request>";
                             requestMain += "    </Execute>";
                             requestMain += "  </s:Body>";
                             requestMain += "</s:Envelope>";
                             var req = new XMLHttpRequest();
                             req.open("POST", SDK.SAMPLES._getServerUrl(), true)
                             // Responses will return XML. It isn't possible to return JSON.
                             req.setRequestHeader("Accept", "application/xml, text/xml, */*");
                             req.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
                             req.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute");
                             var successCallback = null;
                             var errorCallback = null;
                             req.onreadystatechange = function () { SDK.SAMPLES.RemoveItemCampaignResponse(req, successCallback, errorCallback); };
                             req.send(requestMain);
                         },
                     RemoveItemCampaignResponse: function (req, successCallback, errorCallback) {
                             ///<summary>
                             /// Recieves the assign response
                             ///</summary>
                             ///<param name="req" Type="XMLHttpRequest">
                             /// The XMLHttpRequest response
                             ///</param>
                             ///<param name="successCallback" Type="Function">
                             /// The function to perform when an successfult response is returned.
                             /// For this message no data is returned so a success callback is not really necessary.
                             ///</param>
                             ///<param name="errorCallback" Type="Function">
                             /// The function to perform when an error is returned.
                             /// This function accepts a JScript error returned by the _getError function
                             ///</param>
                             if (req.readyState == 4) {
                             if (req.status == 200) {
                             if (successCallback != null)
                             { successCallback(); }
                             }
                             else {
                                 errorCallback(SDK.SAMPLES._getError(req.responseXML));
                             }
                         }
                     },
                     _getError: function (faultXml) {
                         ///<summary>
                         /// Parses the WCF fault returned in the event of an error.
                         ///</summary>
                         ///<param name="faultXml" Type="XML">
                         /// The responseXML property of the XMLHttpRequest response.
                         ///</param>
                         var errorMessage = "Unknown Error (Unable to parse the fault)";
                         if (typeof faultXml == "object") {
                             try {
                                 var bodyNode = faultXml.firstChild.firstChild;
                                 //Retrieve the fault node
                                 for (var i = 0; i < bodyNode.childNodes.length; i++) {
                                     var node = bodyNode.childNodes[i];
                                     //NOTE: This comparison does not handle the case where the XML namespace changes
                                     if ("s:Fault" == node.nodeName) {
                                     for (var j = 0; j < node.childNodes.length; j++) {
                                         var faultStringNode = node.childNodes[j];
                                         if ("faultstring" == faultStringNode.nodeName) {
                                             errorMessage = faultStringNode.text;
                                             break;
                                         }
                                     }
                                     break;
                                 }
                             }
                         }
                         catch (e) { };
                      }
                      return new Error(errorMessage);
                   },
               __namespace: true
              };
              
              


              To understand how to parse the response please review my post on using the DOM parser.
              Now you can call the SDK.SAMPLES.RemoveItemCampaignRequest function from your form jscript handler.


              Thats all there is to it!
              -

              Wednesday, November 30, 2011

              Determine the User ID GUID of a Calling User in Microsoft Dynamics CRM 2011 Using .NET or Jscript With WhoAmIRequest

              This illustration shows how to determine the user id guid of a calling user in Microsoft Dynamics CRM 2011 with WhoAmIRequest.  This example will be given in Jscript (SOAP) and in C# (.NET).
                Ok, here is what the code looks like!
                First in C#:

                 WhoAmIRequest req = new WhoAmIRequest();
                 WhoAmIResponse resp = (WhoAmIResponse)service.Execute(req);
                
                

                If you need help instantiating a service object in .NET within a plugin check out this post:
                http://mileyja.blogspot.com/2011/04/instantiating-service-object-within.html

                Now here is the Jscript nicely formatted by the CRM 2011 SOAP formatter. Available at: http://crm2011soap.codeplex.com/

                Now in Jscript


                This example is asynchronous, if you want to learn how to make JScript SOAP calls synchronously please visit this post: http://mileyja.blogspot.com/2011/07/using-jscript-to-access-soap-web.html

                
                if (typeof (SDK) == "undefined")
                   { SDK = { __namespace: true }; }
                       //This will establish a more unique namespace for functions in this library. This will reduce the 
                       // potential for functions to be overwritten due to a duplicate name when the library is loaded.
                       SDK.SAMPLES = {
                           _getServerUrl: function () {
                               ///<summary>
                               /// Returns the URL for the SOAP endpoint using the context information available in the form
                               /// or HTML Web resource.
                               ///</summary>
                               var OrgServicePath = "/XRMServices/2011/Organization.svc/web";
                               var serverUrl = "";
                               if (typeof GetGlobalContext == "function") {
                                   var context = GetGlobalContext();
                                   serverUrl = context.getServerUrl();
                               }
                               else {
                                   if (typeof Xrm.Page.context == "object") {
                                         serverUrl = Xrm.Page.context.getServerUrl();
                                   }
                                   else
                                   { throw new Error("Unable to access the server URL"); }
                                   }
                                  if (serverUrl.match(/\/$/)) {
                                       serverUrl = serverUrl.substring(0, serverUrl.length - 1);
                                   } 
                                   return serverUrl + OrgServicePath;
                               }, 
                           WhoAmIRequest: function () {
                               var requestMain = ""
                               requestMain += "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">";
                               requestMain += "  <s:Body>";
                               requestMain += "    <Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">";
                               requestMain += "      <request i:type=\"b:WhoAmIRequest\" xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\" xmlns:b=\"http://schemas.microsoft.com/crm/2011/Contracts\">";
                               requestMain += "        <a:Parameters xmlns:c=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\" />";
                               requestMain += "        <a:RequestId i:nil=\"true\" />";
                               requestMain += "        <a:RequestName>WhoAmI</a:RequestName>";
                               requestMain += "      </request>";
                               requestMain += "    </Execute>";
                               requestMain += "  </s:Body>";
                               requestMain += "</s:Envelope>";
                               var req = new XMLHttpRequest();
                               req.open("POST", SDK.SAMPLES._getServerUrl(), true)
                               // Responses will return XML. It isn't possible to return JSON.
                               req.setRequestHeader("Accept", "application/xml, text/xml, */*");
                               req.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
                               req.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute");
                               var successCallback = null;
                               var errorCallback = null;
                               req.onreadystatechange = function () { SDK.SAMPLES.WhoAmIResponse(req, successCallback, errorCallback); };
                               req.send(requestMain);
                           },
                       WhoAmIResponse: function (req, successCallback, errorCallback) {
                               ///<summary>
                               /// Recieves the assign response
                               ///</summary>
                               ///<param name="req" Type="XMLHttpRequest">
                               /// The XMLHttpRequest response
                               ///</param>
                               ///<param name="successCallback" Type="Function">
                               /// The function to perform when an successfult response is returned.
                               /// For this message no data is returned so a success callback is not really necessary.
                               ///</param>
                               ///<param name="errorCallback" Type="Function">
                               /// The function to perform when an error is returned.
                               /// This function accepts a JScript error returned by the _getError function
                               ///</param>
                               if (req.readyState == 4) {
                               if (req.status == 200) {
                               if (successCallback != null)
                               { successCallback(); }
                               }
                               else {
                                   errorCallback(SDK.SAMPLES._getError(req.responseXML));
                               }
                           }
                       },
                       _getError: function (faultXml) {
                           ///<summary>
                           /// Parses the WCF fault returned in the event of an error.
                           ///</summary>
                           ///<param name="faultXml" Type="XML">
                           /// The responseXML property of the XMLHttpRequest response.
                           ///</param>
                           var errorMessage = "Unknown Error (Unable to parse the fault)";
                           if (typeof faultXml == "object") {
                               try {
                                   var bodyNode = faultXml.firstChild.firstChild;
                                   //Retrieve the fault node
                                   for (var i = 0; i < bodyNode.childNodes.length; i++) {
                                       var node = bodyNode.childNodes[i];
                                       //NOTE: This comparison does not handle the case where the XML namespace changes
                                       if ("s:Fault" == node.nodeName) {
                                       for (var j = 0; j < node.childNodes.length; j++) {
                                           var faultStringNode = node.childNodes[j];
                                           if ("faultstring" == faultStringNode.nodeName) {
                                               errorMessage = faultStringNode.text;
                                               break;
                                           }
                                       }
                                       break;
                                   }
                               }
                           }
                           catch (e) { };
                        }
                        return new Error(errorMessage);
                     },
                 __namespace: true
                };
                
                


                To understand how to parse the response please review my post on using the DOM parser.
                Now you can call the SDK.SAMPLES.WhoAmIRequest function from your form jscript handler.


                Thats all there is to it!
                -