loli
Tue Jul 22 10:15:00 CDT 2008
You were right ! it works perfectly !! so impressed :-)
I'm gona try to do it to count the number of contracts for an account and I
let you know.
The best should to have one for account or contact with the number of
activity/history/contract/serviceappoitment...
Don't you think ?
"Mark Braithwaite" wrote:
> Hi
>
> I tested this on the case form and works perfectly. Just paste this into the
> OnLoad event and remove the 5th or 7th line depending on which version of CRM
> you are running.
>
> Wish I could get the 'number of activities' working though.
>
> Regards
> Mark
>
> "loli" wrote:
>
> > That's great ! It's not exactly I need for my orders, but for another
> > application, it can be so useful.
> > Thanks so much to share it
> >
> > In your opinion : I don't really understand where you have to insert this
> > code :
> > If you want to count the number of serviceappoitment for an order, you have
> > to insert in "onload" on the orderform ?
> >
> >
> >
> > "Mark Braithwaite" wrote:
> >
> > > Hi
> > >
> > > Please take a look at the following:
> > >
http://jianwang.blogspot.com/2008/02/show-how-many-activitieshistory.html
> > > Not quite what I hoped for however this may meet some of our needs. It may
> > > be a suitable substitute.
> > >
> > > Regards
> > > Mark
> > >
> > > "loli" wrote:
> > >
> > > > Hello
> > > >
> > > > I have the same pb. I tryied to do it like you did Mark but it does not work.
> > > >
> > > > Just to let you know :-)
> > > >
> > > > "Mark Braithwaite" wrote:
> > > >
> > > > > Hi
> > > > >
> > > > > I have posted the script in the OnLoad Event and noticed the 'Error on Page'
> > > > > message when I opened a case form. This functionality is a bit beyond my
> > > > > capabilities.
> > > > >
> > > > > I would really appreciate any assistance.
> > > > >
> > > > > Many Thanks
> > > > > Mark
> > > > >
> > > > > "Mark Braithwaite" wrote:
> > > > >
> > > > > > Hi
> > > > > >
> > > > > > Thanks very much for your assistance. I am a bit unsure as to how I go about
> > > > > > uploading the script to CRM. Would you please point me in the right direction?
> > > > > >
> > > > > > Many Thanks
> > > > > > Mark
> > > > > >
> > > > > > "Dodd" wrote:
> > > > > >
> > > > > > > You wouldn't have to write a callout, but you'd need to write a query
> > > > > > > using the CRM web service. See if the following works:
> > > > > > >
> > > > > > > var IncidentId = crmForm.ObjectId;
> > > > > > > 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\">" +
> > > > > > > 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>activitypointer</q1:EntityName>" +
> > > > > > > " <q1:ColumnSet xsi:type=\"q1:ColumnSet\">" +
> > > > > > > " <q1:Attributes>" +
> > > > > > > " <q1:Attribute>activityid</q1:Attribute>" +
> > > > > > > " </q1:Attributes>" +
> > > > > > > " </q1:ColumnSet>" +
> > > > > > > " <q1:Distinct>false</q1:Distinct>" +
> > > > > > > " <q1:Criteria>" +
> > > > > > > " <q1:FilterOperator>And</q1:FilterOperator>"+
> > > > > > > " <q1:Conditions>" +
> > > > > > > " <q1:Condition>" +
> > > > > > > " <q1:AttributeName>regardingobjectid</q1:AttributeName>" +
> > > > > > > " <q1:Operator>Equal</q1:Operator>" +
> > > > > > > " <q1:Values>" +
> > > > > > > " <q1:Value xsi:type=\"xsd:string\">" + IncidentId + " </q1:Value>" +
> > > > > > > " </q1:Values>"+
> > > > > > > " </q1:Condition>" +
> > > > > > > " </q1:Conditions>" +
> > > > > > > " </q1:Criteria>" +
> > > > > > > " </query>" +
> > > > > > > " </RetrieveMultiple>" +
> > > > > > > " </soap:Body>" +
> > > > > > > "</soap:Envelope>" +
> > > > > > > "";
> > > > > > >
> > > > > > > // Send the XML
> > > > > > > var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
> > > > > > >
> > > > > > > xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx",
> > > > > > > false);
> > > > > > > xmlHttpRequest.setRequestHeader("SOAPAction","
http://
> > > > > > > schemas.microsoft.com/crm/2007/WebServices/RetrieveMultiple");
> > > > > > > xmlHttpRequest.setRequestHeader("Content-Type", "text/xml;
> > > > > > > charset=utf-8");
> > > > > > > xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
> > > > > > > xmlHttpRequest.send(xml);
> > > > > > >
> > > > > > > // Get the results
> > > > > > > var resultXml = xmlHttpRequest.responseXML;
> > > > > > > var entityNodes = resultXml.selectNodes("//RetrieveMultipleResult//
> > > > > > > BusinessEntities/BusinessEntity");
> > > > > > > crmForm.all.new_numberofactivities.DataValue = entityNodes.length
> > > > > > >
> > > > > > >
> > > > > > > This simply puts count the number of business entity nodes returned in
> > > > > > > the XML response into a CRM Attribute called New_NumberofActivities.
> > > > > > >