Professional Documents
Culture Documents
FormType==1){
/////////////////////////////////////
////////////////Date //////////////
///////////////////////////////////
var myDate=new Date();
myDate.setDate(myDate.getDate()-1);
crmForm.all.scheduledend.DataValue = myDate;
////////////////////////////////////////////////////
///////////initialization////////////////////////////
///////////////////////////////////////////////////
crmForm.all.to.setAttribute("lookuptypes", "1,2");
if (document.getElementById('OnDemandWorkflowForm') != null){
document.getElementById('OnDemandWorkflowForm').style.display="none";
document.getElementById('convertActivity').style.display="none";
document.getElementById('_MBdocumentallRelatedInformationPaneExpanddocumentall
RelatedInformationPaneLoadContextDatafollowup').style.display="none";
}
var FFT = 1; // 0 for account , 1 for contact
///////////////////////////////////////////////////////////////////
///////////////// F I X ///////////////////////////////////////////
//////////////////////////////////////////////////////////////////
if(crmForm.all.regardingobjectid.DataValue!=null)
{
var hellox = new Array();
hellox = null;
hellox = crmForm.all.regardingobjectid.DataValue;
if(hellox[0]!=null)
{
var theKeyx ="contactid";
var AccountIDx = hellox[0].id;
var theTypex = hellox[0].typename;
if(theTypex =="account")
{
theKeyx = "accountid";
FFT=0;
}
else {
var Accountxml = ""+
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+
"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:x
si=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2
001/XMLSchema\">"
+
GenerateAuthenticationHeader()
+
" <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>"+theTypex+"</q1:EntityName>"
+
" <q1:ColumnSet xsi:type=\"q1:AllColumns\" />"
+
" <q1:Distinct>false</q1:Distinct>"
+
" <q1:Criteria>"
+
" <q1:FilterOperaregardingobjectidr>And</q1:FilterOperaregardingobjectidr>"
+
" <q1:Conditions>"
+
" <q1:Condition>"
+
" <q1:AttributeName>"+theKeyx+"</q1:AttributeName>"
+
" <q1:Operaregardingobjectidr>Like</q1:Operaregardingobjectidr>"
+
" <q1:Values>"
+
" <q1:Value xsi:type=\"xsd:string\">"
+
AccountIDx
+
"</q1:Value>"
+
" </q1:Values>"
+
" </q1:Condition>"
+
" </q1:Conditions>"
+
" </q1:Criteria>"
+
" </query>"
+
" </RetrieveMultiple>"
+
" </soap:Body>"
+
"</soap:Envelope>"
+"";
/*
Create the ActiveX object. Once again, this is standard proregardingobjectidcol.
Notice the
last two lines that pass our Query XML that we created above.
*/
/*
Create a container for the "nodes" retrieved. Essentially, these are just the
fields that are returned in the XML result.
*/
var entityNodesx = resultAccountXml.selectNodes("//RetrieveMultipleResult/Busine
ssEntities/BusinessEntity");
/* Loop through the collection of returned entities.
Note that the query above limits the result regardingobjectid a single entity,
so you will only find one
node. regardingobjectid be more specific, it could be 0 nodes as well, if you d
on??t have access regardingobjectid accounts
or your system is empty. */
for (var i = 0; i < entityNodesx.length; i++)
{
var entityNodex = entityNodesx[i];
if(entityNodex.selectSingleNode('//q1:parentcusregardingobjectidmerid') != null
&& crmForm.FormType==1){
var lookupObject = new Object;
var lookupObjectArray = new Array();
lookupObject.id = entityNodex.selectSingleNode('//q1:parentcusregardingobject
idmerid').nodeTypedValue;
lookupObject.typename = "account";
lookupObject.name = entityNodex.selectSingleNode('//q1:parentcusregardingobje
ctidmerid').getAttribute("name");
lookupObjectArray[0] = lookupObject;
crmForm.all.regardingobjectid.DataValue = lookupObjectArray;
crmForm.all.regardingobjectid.ForceSubmit = true;
} else {crmForm.all.regardingobjectid.DataValue = null;
}
}
///////////////////////
}
}
}
//////////////////////////////////////////////////////////////////
///////////account for account////////////////////////////////
/////////////////////////////////////////////////////////////////
if(FFT == 0)
{
crmForm.all.to.Value = null;
}
if(crmForm.all.regardingobjectid.DataValue!=null){
var hello = new Array();
hello = null;
hello = crmForm.all.regardingobjectid.DataValue;
if(hello[0]!=null)
{
var theKey ="contactid";
var AccountID = hello[0].id;
var theType = hello[0].typename;
if(theType =="account"){theKey = "accountid";}
var Accountxml = ""+
"<?xml version=\"1.0\" encoding=\"utf-8\"?>"
+
"<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:x
si=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2
001/XMLSchema\">"
+
GenerateAuthenticationHeader()
+
" <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>"+theType+"</q1:EntityName>"
+
" <q1:ColumnSet xsi:type=\"q1:AllColumns\" />"
+
" <q1:Distinct>false</q1:Distinct>"
+
" <q1:Criteria>"
+
" <q1:FilterOperaregardingobjectidr>And</q1:FilterOperaregardingobjectidr>"
+
" <q1:Conditions>"
+
" <q1:Condition>"
+
" <q1:AttributeName>"+theKey+"</q1:AttributeName>"
+
" <q1:Operaregardingobjectidr>Like</q1:Operaregardingobjectidr>"
+
" <q1:Values>"
+
" <q1:Value xsi:type=\"xsd:string\">"
+
AccountID
+
"</q1:Value>"
+
" </q1:Values>"
+
" </q1:Condition>"
+
" </q1:Conditions>"
+
" </q1:Criteria>"
+
" </query>"
+
" </RetrieveMultiple>"
+
" </soap:Body>"
+
"</soap:Envelope>"
+"";
/*
Create the ActiveX object. Once again, this is standard proregardingobjectidcol.
Notice the
last two lines that pass our Query XML that we created above.
*/
var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2
007/WebServices/RetrieveMultiple");
xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
xmlHttpRequest.setRequestHeader("Content-Length", Accountxml.length);
xmlHttpRequest.send(Accountxml);
/* Set the XML response regardingobjectid a variable that can be parsed later.
*/
var resultAccountXml = xmlHttpRequest.responseXML;
/*
Create a container for the "nodes" retrieved. Essentially, these are just the
fields that are returned in the XML result.
*/
var entityNodes = resultAccountXml.selectNodes("//RetrieveMultipleResult/Busines
sEntities/BusinessEntity");
/* Loop through the collection of returned entities.
Note that the query above limits the result regardingobjectid a single entity,
so you will only find one
node. regardingobjectid be more specific, it could be 0 nodes as well, if you d
on??t have access regardingobjectid accounts
or your system is empty. */
for (var i = 0; i < entityNodes.length; i++)
{
/* Access the current array element */
var entityNode = entityNodes[i];