How to easily close many CRM 4.0 activities in one shot ?
This sample allows you to add a button in order to close selected activities
in one shot.
Install:
- Export the ISV config file.
- extract the file and open it in an text editor.
- Update the isv config file with this source code (‘activitypointer’ section )
<ImportExportXml version="4.0.0.0" languagecode="1033" generatedBy="OnPremise"> <Entities> </Entities> <Roles> </Roles> <Workflows> </Workflows> <IsvConfig> <configuration version="3.0.0000.0"> <Root> </Root> <!-- Microsoft Customer Relationship Management Entities (Objects) --> <Entities> <Entity name="activitypointer"> <Grid> <MenuBar> <Buttons> <Button Icon="/_imgs/ico_18_debug.gif" JavaScript=" var grid = document.getElementById('gridBodyTable'); var a = document.all['crmGrid'].InnerGrid.SelectedRecords; var selectedItems = new Array(a.length); for (var i=0; i < a.length; i++) { var stateReq = ''; var stateType = ''; var state = 'Completed'; var status = '-1'; if(a[i][1] == '4212') { stateReq = 'SetStateTaskRequest'; stateType= 'Task'; } else if(a[i][1] == '4210') { stateReq = 'SetStatePhoneCallRequest'; stateType= 'PhoneCall'; } else if(a[i][1] == '4207') { stateReq = 'SetStateLetterRequest'; stateType= 'Letter'; } else if(a[i][1] == '4204') { stateReq = 'SetStateFaxRequest'; stateType= 'Fax'; } else if(a[i][1] == '4214') { stateReq = 'SetStateServiceAppointmentRequest'; stateType= 'ServiceAppointment'; state = 'Closed'; } else if(a[i][1] == '4201') { stateReq = 'SetStateAppointmentRequest'; stateType= 'Appointment'; } else if(a[i][1] == '4402') { stateReq = 'SetStateCampaignActivityRequest'; stateType= 'CampaignActivity'; state = 'Closed'; } else if(a[i][1] == '4401') { stateReq = 'SetStateCampaignResponseRequest'; stateType= 'CampaignResponse'; } else if(a[i][1] == '4202') { stateReq = 'SetStateEmailRequest'; stateType= 'Email'; } var xml = '' + '<?xml version="1.0" encoding="utf-8"?>' + '<soap:Envelope xmlns:soap="https://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="https://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="https://www.w3.org/2001/XMLSchema">' + ' <soap:Header>' + ' <CrmAuthenticationToken xmlns="https://schemas.microsoft.com/crm/2007/WebServices">' + ' <AuthenticationType xmlns="https://schemas.microsoft.com/crm/2007/CoreTypes">0</AuthenticationType>' + ' <OrganizationName xmlns="https://schemas.microsoft.com/crm/2007/CoreTypes">Microsoft</OrganizationName>' + ' <CallerId xmlns="https://schemas.microsoft.com/crm/2007/CoreTypes">00000000-0000-0000-0000-000000000000</CallerId>' + ' </CrmAuthenticationToken>' + ' </soap:Header>' + ' <soap:Body>' + ' <Execute xmlns="https://schemas.microsoft.com/crm/2007/WebServices">' + ' <Request xsi:type="'+stateReq+'">' + ' <EntityId>' + a[i][0] + '</EntityId>' + ' <'+stateType+'State>'+state+'</'+stateType+'State>'+ ' <'+stateType+'Status>' + status + '</'+stateType+'Status>'+ ' </Request>' + ' </Execute>' + ' </soap:Body>' + '</soap:Envelope>' + ''; var xmlHttpRequest = new ActiveXObject('Msxml2.XMLHTTP'); xmlHttpRequest.Open('POST', '/mscrmservices/2007/CrmService.asmx', false); xmlHttpRequest.setRequestHeader('SOAPAction','https://schemas.microsoft.com/crm/2007/WebServices/Execute'); xmlHttpRequest.setRequestHeader('Content-Type', 'text/xml; charset=utf-8'); xmlHttpRequest.setRequestHeader('Content-Length', xml.length); xmlHttpRequest.send(xml); var resultXml = xmlHttpRequest.responseXML; } window.crmGrid.Refresh(); " Client="Web" AvailableOffline="true"> <Titles> <Title LCID="1033" Text="Close Activities" /> </Titles> <ToolTips> <ToolTip LCID="1033" Text="Close Activities for selected records" /> </ToolTips> </Button> </Buttons> </MenuBar> </Grid> </Entity> </Entities> </configuration> </IsvConfig> <EntityMaps /> <EntityRelationships /> <Languages> <Language>1033</Language> </Languages> </ImportExportXml> |
-import in CRM the isv config file.
Pierre-Adrien FORESTIER | PAF | https://blogs.msdn.com/paf
Comments
Anonymous
September 08, 2010
This is just what I am looking for, but when I tried it I got prompted for an authentication dialogue for each record in the grid. Is there something else I need to do to get it to work?Anonymous
November 01, 2010
Replace the soap header with GenerateAuthenticationHeader().Anonymous
February 08, 2011
The easiest way I've found is to create an on demand workflow for each activity type and run the work flow on selected records to set the status to completed.Anonymous
December 24, 2011
Fantastic very clever way of implementing Thanks for the post