Hi,
Here is fnunction to hide field in client Side, Javascript:
function HideField(fieldName, visible) {
var label = document.getElementById(fieldName + '_c');
var value = document.getElementById(fieldName + '_d');
if (label)
label.style.display = visible ? 'inline' : 'none';
if (value)
value.style.display = visible ? 'inline' : 'none';
}
thanks,
Rami Heleg
This site helps you to develop in the easy way Microsoft Dynamics CRM. Microsoft Dynamics CRM includes many examples to develop for Microsoft Dynamics CRM.
Showing posts with label Client. Show all posts
Showing posts with label Client. Show all posts
Monday, July 19, 2010
Monday, July 12, 2010
Set in client Side values into disabled field
To set value into disabled field must set values like that:
crmForm.all.new_myfield.ForceSubmit = true;
crmForm.all.new_myfield.defaultValue = crmForm.all.new_myfield.DataValue = value;
by default crm doesn't send disbaled values from client to server in save entity.
thanks,
Rami Heleg
crmForm.all.new_myfield.ForceSubmit = true;
crmForm.all.new_myfield.defaultValue = crmForm.all.new_myfield.DataValue = value;
by default crm doesn't send disbaled values from client to server in save entity.
thanks,
Rami Heleg
Tuesday, December 29, 2009
Update Method using Java Script
Hi,
Here is an example to update entoty request only in Client Side
// Prepare variables for updating a contact.
var contactId = "56914948-991C-DD11-AD3A-0003FF9EE217";
var newAddressLine1 = "34 Market St.";
var authenticationHeader = GenerateAuthenticationHeader();
// Prepare the SOAP message.
var xml = "<?xml version='1.0' encoding='utf-8'?>"+
"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'"+
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+
" xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"+
authenticationHeader+
"<soap:Body>"+
"<Update xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
"<entity xsi:type='contact'>"+
"<address1_line1>"+newAddressLine1+"</address1_line1>"+
"<contactid>"+contactId+"</contactid>"+
"</entity>"+
"</Update>"+
"</soap:Body>"+
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request.
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Update");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result
var resultXml = xHReq.responseXML;
// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}
// Display a confirmation message and open the updated contact.
else
{
alert("Contact with id = "+contactId+" successfully updated.");
window.open("/sfa/conts/edit.aspx?id={"+contactId+"}");
}
Enjoy,
Rami Heleg
Here is an example to update entoty request only in Client Side
// Prepare variables for updating a contact.
var contactId = "56914948-991C-DD11-AD3A-0003FF9EE217";
var newAddressLine1 = "34 Market St.";
var authenticationHeader = GenerateAuthenticationHeader();
// Prepare the SOAP message.
var xml = "<?xml version='1.0' encoding='utf-8'?>"+
"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'"+
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+
" xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"+
authenticationHeader+
"<soap:Body>"+
"<Update xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
"<entity xsi:type='contact'>"+
"<address1_line1>"+newAddressLine1+"</address1_line1>"+
"<contactid>"+contactId+"</contactid>"+
"</entity>"+
"</Update>"+
"</soap:Body>"+
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request.
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Update");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result
var resultXml = xHReq.responseXML;
// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}
// Display a confirmation message and open the updated contact.
else
{
alert("Contact with id = "+contactId+" successfully updated.");
window.open("/sfa/conts/edit.aspx?id={"+contactId+"}");
}
Enjoy,
Rami Heleg
RetrieveMultiple Method Using Java Script
Hi,
Here is an example to RetrieveMultiple only in Client Side
// Prepare variables to retrieve the contacts.
var searchCity = "Sammamish";
var authenticationHeader = GenerateAuthenticationHeader();
// Prepare the SOAP message.
var xml = "<?xml version='1.0' encoding='utf-8'?>"+
"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'"+
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+
" xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"+
authenticationHeader+
"<soap:Body>"+
"<RetrieveMultiple xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
"<query xmlns:q1='http://schemas.microsoft.com/crm/2006/Query'"+
" xsi:type='q1:QueryExpression'>"+
"<q1:EntityName>contact</q1:EntityName>"+
"<q1:ColumnSet xsi:type='q1:ColumnSet'>"+
"<q1:Attributes>"+
"<q1:Attribute>fullname</q1:Attribute>"+
"<q1:Attribute>contactid</q1:Attribute>"+
"</q1:Attributes>"+
"</q1:ColumnSet>"+
"<q1:Distinct>false</q1:Distinct>"+
"<q1:Criteria>"+
"<q1:FilterOperator>And</q1:FilterOperator>"+
"<q1:Conditions>"+
"<q1:Condition>"+
"<q1:AttributeName>address1_city</q1:AttributeName>"+
"<q1:Operator>Like</q1:Operator>"+
"<q1:Values>"+
"<q1:Value xsi:type='xsd:string'>"+searchCity+"</q1:Value>"+
"</q1:Values>"+
"</q1:Condition>"+
"</q1:Conditions>"+
"</q1:Criteria>"+
"</query>"+
"</RetrieveMultiple>"+
"</soap:Body>"+
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request.
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result.
var resultXml = xHReq.responseXML;
// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}
Enjoy,
Rami Heleg
Here is an example to RetrieveMultiple only in Client Side
// Prepare variables to retrieve the contacts.
var searchCity = "Sammamish";
var authenticationHeader = GenerateAuthenticationHeader();
// Prepare the SOAP message.
var xml = "<?xml version='1.0' encoding='utf-8'?>"+
"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'"+
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+
" xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"+
authenticationHeader+
"<soap:Body>"+
"<RetrieveMultiple xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
"<query xmlns:q1='http://schemas.microsoft.com/crm/2006/Query'"+
" xsi:type='q1:QueryExpression'>"+
"<q1:EntityName>contact</q1:EntityName>"+
"<q1:ColumnSet xsi:type='q1:ColumnSet'>"+
"<q1:Attributes>"+
"<q1:Attribute>fullname</q1:Attribute>"+
"<q1:Attribute>contactid</q1:Attribute>"+
"</q1:Attributes>"+
"</q1:ColumnSet>"+
"<q1:Distinct>false</q1:Distinct>"+
"<q1:Criteria>"+
"<q1:FilterOperator>And</q1:FilterOperator>"+
"<q1:Conditions>"+
"<q1:Condition>"+
"<q1:AttributeName>address1_city</q1:AttributeName>"+
"<q1:Operator>Like</q1:Operator>"+
"<q1:Values>"+
"<q1:Value xsi:type='xsd:string'>"+searchCity+"</q1:Value>"+
"</q1:Values>"+
"</q1:Condition>"+
"</q1:Conditions>"+
"</q1:Criteria>"+
"</query>"+
"</RetrieveMultiple>"+
"</soap:Body>"+
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request.
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result.
var resultXml = xHReq.responseXML;
// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}
Enjoy,
Rami Heleg
Retrieve Method Using JScript
Hi,
Here is an example to retrieve data only in Client Side
// Prepare variables for a contact to retrieve.
var contactid = "4696f8cb-9a1c-dd11-ad3a-0003ff9ee217";
var authenticationHeader = GenerateAuthenticationHeader();
// Prepare the SOAP message.
var xml = "<?xml version='1.0' encoding='utf-8'?>"+
"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'"+
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+
" xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"+
authenticationHeader+
"<soap:Body>"+
"<Retrieve xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
"<entityName>contact</entityName>"+
"<id>"+contactid+"</id>"+
"<columnSet xmlns:q1='http://schemas.microsoft.com/crm/2006/Query' xsi:type='q1:ColumnSet'>"+
"<q1:Attributes>"+
"<q1:Attribute>fullname</q1:Attribute>"+
"</q1:Attributes>"+
"</columnSet>"+
"</Retrieve>"+
"</soap:Body>"+
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request.
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Retrieve");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result.
var resultXml = xHReq.responseXML;
// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}
// Display the retrieved value.
else
{
alert(resultXml.selectSingleNode("//q1:fullname").nodeTypedValue);
}
The following is an example of a successful response:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<RetrieveResponse xmlns="http://schemas.microsoft.com/crm/2007/WebServices">
<RetrieveResult xmlns:q1="http://schemas.microsoft.com/crm/2007/WebServices" xsi:type="q1:contact">
<q1:fullname>Jesper Aaberg</q1:fullname>
<q1:contactid>{4696F8CB-9A1C-DD11-AD3A-0003FF9EE217}</q1:contactid>
<q1:owningbusinessunit>{0EA35030-3EC9-DC11-A8D2-0003FF9EE217}</q1:owningbusinessunit>
</RetrieveResult>
</RetrieveResponse>
</soap:Body>
</soap:Envelope>
Enjoy,
Rami Heleg
Here is an example to retrieve data only in Client Side
// Prepare variables for a contact to retrieve.
var contactid = "4696f8cb-9a1c-dd11-ad3a-0003ff9ee217";
var authenticationHeader = GenerateAuthenticationHeader();
// Prepare the SOAP message.
var xml = "<?xml version='1.0' encoding='utf-8'?>"+
"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'"+
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+
" xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"+
authenticationHeader+
"<soap:Body>"+
"<Retrieve xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
"<entityName>contact</entityName>"+
"<id>"+contactid+"</id>"+
"<columnSet xmlns:q1='http://schemas.microsoft.com/crm/2006/Query' xsi:type='q1:ColumnSet'>"+
"<q1:Attributes>"+
"<q1:Attribute>fullname</q1:Attribute>"+
"</q1:Attributes>"+
"</columnSet>"+
"</Retrieve>"+
"</soap:Body>"+
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request.
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Retrieve");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result.
var resultXml = xHReq.responseXML;
// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}
// Display the retrieved value.
else
{
alert(resultXml.selectSingleNode("//q1:fullname").nodeTypedValue);
}
The following is an example of a successful response:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<RetrieveResponse xmlns="http://schemas.microsoft.com/crm/2007/WebServices">
<RetrieveResult xmlns:q1="http://schemas.microsoft.com/crm/2007/WebServices" xsi:type="q1:contact">
<q1:fullname>Jesper Aaberg</q1:fullname>
<q1:contactid>{4696F8CB-9A1C-DD11-AD3A-0003FF9EE217}</q1:contactid>
<q1:owningbusinessunit>{0EA35030-3EC9-DC11-A8D2-0003FF9EE217}</q1:owningbusinessunit>
</RetrieveResult>
</RetrieveResponse>
</soap:Body>
</soap:Envelope>
Enjoy,
Rami Heleg
Run Fetch Method using java script
Hi,
Here is an example to execute fetch only in Client Side
// Prepare variables to fetch accounts.
var fetchMapping = "logical";
var entityName = "account";
var firstColumn = "accountid";
var secondColumn = "name";
var linkEntity = "systemuser";
var linkEntityTo ="owninguser";
var filterType = "and";
var conditionAttribute = "lastname";
var operator = "ne";
var value = "Cannon";
var authenticationHeader = GenerateAuthenticationHeader();
// Prepare the SOAP message.
var xml = "<?xml version='1.0' encoding='utf-8'?>"+
"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'"+
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+
" xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"+
authenticationHeader+
"<soap:Body>"+
"<Fetch xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
"<fetchXml><fetch mapping='"+fetchMapping+"'>"+
"<entity name='"+entityName+"'>"+
"<attribute name='"+firstColumn+"'/>"+
"<attribute name='"+secondColumn+"'/>"+
"<link-entity name='"+linkEntity+"' to='"+linkEntityTo+"'>"+
"<filter type='"+filterType+"'>"+
"<condition attribute='"+conditionAttribute+"'"+
" operator='"+operator+"' value='"+value+"'/>"+
"</filter>"+
"</link-entity>"+
"</entity>"+
"</fetch></fetchXml>"+
"</Fetch>"+
"</soap:Body>"+
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request.
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Fetch");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result.
var resultXml = xHReq.responseXML;
// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}
Enjoy,
Rami Heleg
Here is an example to execute fetch only in Client Side
// Prepare variables to fetch accounts.
var fetchMapping = "logical";
var entityName = "account";
var firstColumn = "accountid";
var secondColumn = "name";
var linkEntity = "systemuser";
var linkEntityTo ="owninguser";
var filterType = "and";
var conditionAttribute = "lastname";
var operator = "ne";
var value = "Cannon";
var authenticationHeader = GenerateAuthenticationHeader();
// Prepare the SOAP message.
var xml = "<?xml version='1.0' encoding='utf-8'?>"+
"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'"+
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+
" xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"+
authenticationHeader+
"<soap:Body>"+
"<Fetch xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
"<fetchXml><fetch mapping='"+fetchMapping+"'>"+
"<entity name='"+entityName+"'>"+
"<attribute name='"+firstColumn+"'/>"+
"<attribute name='"+secondColumn+"'/>"+
"<link-entity name='"+linkEntity+"' to='"+linkEntityTo+"'>"+
"<filter type='"+filterType+"'>"+
"<condition attribute='"+conditionAttribute+"'"+
" operator='"+operator+"' value='"+value+"'/>"+
"</filter>"+
"</link-entity>"+
"</entity>"+
"</fetch></fetchXml>"+
"</Fetch>"+
"</soap:Body>"+
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request.
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Fetch");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result.
var resultXml = xHReq.responseXML;
// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}
Enjoy,
Rami Heleg
Execute Method using Java Script
Hi,
Here is an example to execute request only in Client Side
// Prepare variables to add a new product to a campaign.
var CampaignId = "771ed82b-6b27-dd11-b452-0003ff9ee217";
var EntityId = "3F26C82A-A2E1-DC11-A277-001AA0B84538";
var EntityName = "product";
var authenticationHeader = GenerateAuthenticationHeader();
// Prepare the SOAP message.
var xml = "<?xml version='1.0' encoding='utf-8'?>"+
"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'"+
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+
" xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"+
authenticationHeader+
"<soap:Body>"+
"<Execute xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
"<Request xsi:type='AddItemCampaignRequest'>"+
"<CampaignId>"+CampaignId+"</CampaignId>"+
"<EntityId>"+EntityId+"</EntityId>"+
"<EntityName>"+EntityName+"</EntityName>"+
"</Request>"+
"</Execute>"+
"</soap:Body>"+
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request.
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Execute");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result.
var resultXml = xHReq.responseXML;
// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}
// Display a confirmation message and open the campaign record.
else
{
alert("Product with id = "+EntityId+" successfully added to Campaign with id = "+CampaignId+".");
window.open("/ma/camps/edit.aspx?id={"+CampaignId+"}");
}
Enjoy,
Rami Heleg
Here is an example to execute request only in Client Side
// Prepare variables to add a new product to a campaign.
var CampaignId = "771ed82b-6b27-dd11-b452-0003ff9ee217";
var EntityId = "3F26C82A-A2E1-DC11-A277-001AA0B84538";
var EntityName = "product";
var authenticationHeader = GenerateAuthenticationHeader();
// Prepare the SOAP message.
var xml = "<?xml version='1.0' encoding='utf-8'?>"+
"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'"+
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+
" xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"+
authenticationHeader+
"<soap:Body>"+
"<Execute xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
"<Request xsi:type='AddItemCampaignRequest'>"+
"<CampaignId>"+CampaignId+"</CampaignId>"+
"<EntityId>"+EntityId+"</EntityId>"+
"<EntityName>"+EntityName+"</EntityName>"+
"</Request>"+
"</Execute>"+
"</soap:Body>"+
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request.
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Execute");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result.
var resultXml = xHReq.responseXML;
// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}
// Display a confirmation message and open the campaign record.
else
{
alert("Product with id = "+EntityId+" successfully added to Campaign with id = "+CampaignId+".");
window.open("/ma/camps/edit.aspx?id={"+CampaignId+"}");
}
Enjoy,
Rami Heleg
Delete Entity in Client Side ( Java Script only)
Hi,
here is an example to delete entity only in client side:
// Identify the contact to delete.
var contactid = "57a4e111-7027-dd11-b452-0003ff9ee217";
var authenticationHeader = GenerateAuthenticationHeader();
// Prepare the SOAP message.
var xml = "<?xml version='1.0' encoding='utf-8'?>"+
"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'"+
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+
" xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"+
authenticationHeader+
"<soap:Body>"+
"<Delete xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
"<entityName>contact</entityName>"+
"<id>"+contactid+"</id>"+
"</Delete>"+
"</soap:Body>"+
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request,
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Delete");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result,
var resultXml = xHReq.responseXML;
// Check for errors,
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}
// Display confirmation message.
else
{
alert("Contact with id = "+contactid+" successfully deleted");
}
Enjoy,
Rami Heleg
here is an example to delete entity only in client side:
// Identify the contact to delete.
var contactid = "57a4e111-7027-dd11-b452-0003ff9ee217";
var authenticationHeader = GenerateAuthenticationHeader();
// Prepare the SOAP message.
var xml = "<?xml version='1.0' encoding='utf-8'?>"+
"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'"+
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+
" xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"+
authenticationHeader+
"<soap:Body>"+
"<Delete xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
"<entityName>contact</entityName>"+
"<id>"+contactid+"</id>"+
"</Delete>"+
"</soap:Body>"+
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request,
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Delete");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result,
var resultXml = xHReq.responseXML;
// Check for errors,
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}
// Display confirmation message.
else
{
alert("Contact with id = "+contactid+" successfully deleted");
}
Enjoy,
Rami Heleg
Create Entity in client side ( Java Script only)
Hi,
here is an example of create entity only in client side:
// Prepare values for the new contact.
var firstname = "Jesper";
var lastname = "Aaberg";
var donotbulkemail = "true";
var address1_stateorprovince = "MT";
var address1_postalcode = "99999";
var address1_line1 = "23 Market St.";
var address1_city = "Sammamish";
var authenticationHeader = GenerateAuthenticationHeader();
// Prepare the SOAP message.
var xml = "<?xml version'1.0' encoding='utf-8'?>" +
"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'"+
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+
" xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"+
authenticationHeader+
"<soap:Body>"+
"<Create xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
"<entity xsi:type='contact'>"+
"<address1_city>"+address1_city+"</address1_city>"+
"<address1_line1>"+address1_line1+"</address1_line1>"+
"<address1_postalcode>"+address1_postalcode+"</address1_postalcode>"+
"<address1_stateorprovince>"+address1_stateorprovince+"</address1_stateorprovince>"+
"<donotbulkemail>"+donotbulkemail+"</donotbulkemail>"+
"<firstname>"+firstname+"</firstname>"+
"<lastname>"+lastname+"</lastname>"+
"</entity>"+
"</Create>"+
"</soap:Body>"+
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request.
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Create");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result
var resultXml = xHReq.responseXML;
// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}
// Open new contact record if no errors.
else
{
var contactid = resultXml.selectSingleNode("//CreateResult");
window.open("/sfa/conts/edit.aspx?id={"+contactid.nodeTypedValue+"}");
}
Enjoy,
Rami Heleg
here is an example of create entity only in client side:
// Prepare values for the new contact.
var firstname = "Jesper";
var lastname = "Aaberg";
var donotbulkemail = "true";
var address1_stateorprovince = "MT";
var address1_postalcode = "99999";
var address1_line1 = "23 Market St.";
var address1_city = "Sammamish";
var authenticationHeader = GenerateAuthenticationHeader();
// Prepare the SOAP message.
var xml = "<?xml version'1.0' encoding='utf-8'?>" +
"<soap:Envelope xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'"+
" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'"+
" xmlns:xsd='http://www.w3.org/2001/XMLSchema'>"+
authenticationHeader+
"<soap:Body>"+
"<Create xmlns='http://schemas.microsoft.com/crm/2007/WebServices'>"+
"<entity xsi:type='contact'>"+
"<address1_city>"+address1_city+"</address1_city>"+
"<address1_line1>"+address1_line1+"</address1_line1>"+
"<address1_postalcode>"+address1_postalcode+"</address1_postalcode>"+
"<address1_stateorprovince>"+address1_stateorprovince+"</address1_stateorprovince>"+
"<donotbulkemail>"+donotbulkemail+"</donotbulkemail>"+
"<firstname>"+firstname+"</firstname>"+
"<lastname>"+lastname+"</lastname>"+
"</entity>"+
"</Create>"+
"</soap:Body>"+
"</soap:Envelope>";
// Prepare the xmlHttpObject and send the request.
var xHReq = new ActiveXObject("Msxml2.XMLHTTP");
xHReq.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xHReq.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Create");
xHReq.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xHReq.setRequestHeader("Content-Length", xml.length);
xHReq.send(xml);
// Capture the result
var resultXml = xHReq.responseXML;
// Check for errors.
var errorCount = resultXml.selectNodes('//error').length;
if (errorCount != 0)
{
var msg = resultXml.selectSingleNode('//description').nodeTypedValue;
alert(msg);
}
// Open new contact record if no errors.
else
{
var contactid = resultXml.selectSingleNode("//CreateResult");
window.open("/sfa/conts/edit.aspx?id={"+contactid.nodeTypedValue+"}");
}
Enjoy,
Rami Heleg
Thursday, December 3, 2009
How to change due date filter default value for activities page:

Sometimes you need to define your default filter values for the home activities page.
Here is an example how to change due date filter default value:
Add this code to "\CRMWeb\Workplace\home_activities.aspx" page:
<script runat="server">
protected override void OnPreRender(EventArgs e) {
base.OnPreRender(e);
this.crmDateSelector.Selected = "Today";
this.crmGrid.Parameters.Add("scheduledend", "Today");
}
</script>
You can set these values to the crmDateSelector control:
Overdue
Today
Tomorrow
NextXDays;7
NextXDays;30
NextXDays;90
NextXMonths;6
NextXMonths;12
All
thanks,
Max Shafranski,
Team blog member.
Thursday, November 12, 2009
Use setInterval, clearInterval in CRM 3/4
Using setInterval if very helpful and powerfull when develop javascript in CRM 3/4.
Special target is to load forms very fast and make other code after user start to work.
This example contain two functions.
loadMyPage() and afterLoading()
function loadMyPage() call to function afterLoading() with interval of one second.
After second function afterLoading() is working..
Don’t forget to make the clearInterval.. clear calling.
function afterLoading() {
window.clearInterval(common_init_interval);
}
function loadMyPage(){
common_init_interval = setInterval('try { afterLoading (); } catch (e) { }', 1000);
}
Enjoy,
Rami Heleg
Special target is to load forms very fast and make other code after user start to work.
This example contain two functions.
loadMyPage() and afterLoading()
function loadMyPage() call to function afterLoading() with interval of one second.
After second function afterLoading() is working..
Don’t forget to make the clearInterval.. clear calling.
function afterLoading() {
window.clearInterval(common_init_interval);
}
function loadMyPage(){
common_init_interval = setInterval('try { afterLoading (); } catch (e) { }', 1000);
}
Enjoy,
Rami Heleg
Handle Grid in IFRAME
Here is an example how to handle grid (like area grid) in IFRAME.
Add these 2 rows where form is loaded to get handle of the iframe
var iframe = document.getElementById('IFRAME_test');
iframe.onreadystatechange = FrameStateChanged;
function to handle iframe state changed like initalize, complete
function FrameStateChanged()
{
var iframe = document.getElementById('IFRAME_test');
if(iframe.readyState == "complete"){
// get grid from iframe
caseGrid = iframe.contentWindow.document.getElementById('crmGrid');
if (caseGrid != null)
caseGrid.attachEvent("onselectionchange",HandleGridSelectionChange);
}
}
// get guid from selected row.. can get all values.
function HandleGridSelectionChange()
{
//select row
var selectedRow = caseGrid.InnerGrid.SelectedRecords;
// get selected guid
if (selectedRow.length > 0)
var guid =selectedRow[0][0];
}
Enjoy,
Rami Heleg
Add these 2 rows where form is loaded to get handle of the iframe
var iframe = document.getElementById('IFRAME_test');
iframe.onreadystatechange = FrameStateChanged;
function to handle iframe state changed like initalize, complete
function FrameStateChanged()
{
var iframe = document.getElementById('IFRAME_test');
if(iframe.readyState == "complete"){
// get grid from iframe
caseGrid = iframe.contentWindow.document.getElementById('crmGrid');
if (caseGrid != null)
caseGrid.attachEvent("onselectionchange",HandleGridSelectionChange);
}
}
// get guid from selected row.. can get all values.
function HandleGridSelectionChange()
{
//select row
var selectedRow = caseGrid.InnerGrid.SelectedRecords;
// get selected guid
if (selectedRow.length > 0)
var guid =selectedRow[0][0];
}
Enjoy,
Rami Heleg
Tuesday, November 3, 2009
Property ForceSubmit
CRM Send parameters from client to server only if IsDirty = true, it means fields has been changed.
this issue good for performance.
to send field value any way to server need to change field property like this example:
crmForm.all.firstname.ForceSubmit = true;
like that if field is disabled or contain the same value the value sent any way to server.
thanks,
Rami Heleg.
this issue good for performance.
to send field value any way to server need to change field property like this example:
crmForm.all.firstname.ForceSubmit = true;
like that if field is disabled or contain the same value the value sent any way to server.
thanks,
Rami Heleg.
Tuesday, September 15, 2009
View Schema via internet explorer
Hi,
Here is an example how to view schema information via internet explorer
http://servername:port/org_name/sdk/list.aspx
enable to view entities, attributes and relationships.
Thanks,
Rami Heleg
Here is an example how to view schema information via internet explorer
http://servername:port/org_name/sdk/list.aspx
enable to view entities, attributes and relationships.
Thanks,
Rami Heleg
Subscribe to:
Posts (Atom)