Archive
Deleting notes attachments using jscript in CRM 2011
Hi,
In CRM, we can add files as attachments to the Notes.
- All the notes get saved in to “Annotation” entity in the data base.
- The attachment information get saved in to below columns of “Annotation” entity
- Document Body
- File Name
- File Size
- Is Document
Deleting attachments using script:-
To delete the attachment using jscript,
- Update the “Document Body,File Name,File Size” fields to null
- And “IsDocument = false” using OData as below
function deleteAttachments(){
var notesId = {GUID of notes};
var objNotes = new Object();
objNotes.DocumentBody = null;
objNotes.FileName = null;
objNotes.FileSize = null;
objNotes.IsDocument = false;
updateRecord(notesId, objNotes, “AnnotationSet”);
}
function updateRecord(id, entityObject, odataSetName) {
var jsonEntity = window.JSON.stringify(entityObject);
var serverUrl = Xrm.Page.context.getServerUrl();
var ODATA_ENDPOINT = “/XRMServices/2011/OrganizationData.svc”;
var updateRecordReq = new XMLHttpRequest();
var ODataPath = serverUrl + ODATA_ENDPOINT;
updateRecordReq.open(‘POST’, ODataPath + “/” + odataSetName + “(guid'” + id + “‘)”, false);
updateRecordReq.setRequestHeader(“Accept”, “application/json”);
updateRecordReq.setRequestHeader(“Content-Type”, “application/json; charset=utf-8”);
updateRecordReq.setRequestHeader(“X-HTTP-Method”, “MERGE”);
updateRecordReq.send(jsonEntity);
}
🙂
Stats
- 1,555,882 hits
Tweets
- RT @TaikiYoshidaEN: Awesome to see we have a shiny new public facing website for Power CAT! 😻😻😻 microsoft.github.io/powercat/ #PowerApps #PowerA… 16 hours ago
- RT @ravichada: 🎥 The demo video is ready now. Do check out the Dataverse Security Roles risk assessment tool in action. Leave a comment or… 16 hours ago
- RT @ManuelaPichler_: CoE kit but make it more fluent-y #comingsoon https://t.co/kcSzPqwZhM 16 hours ago
- New Blog Post: C# Basics | Why Interfaces rajeevpentyala.com/2023/01/07/c-b… 2 weeks ago
- New blog post : Dataverse solution import error | Environment variable value cannot be an empty string rajeevpentyala.com/2023/01/05/dat… 3 weeks ago
Top Posts
- Power Apps component framework (PCF) - Beginner guide
- [Code Snippet] Custom Workflow Activity with Input and Output Params
- [Step by Step] Connecting to Azure SQL Server using OLEDB Connection from SSIS
- Power Automate Flows | 'Callback Registration Expander' System Jobs stuck at 'Waiting For Resources'
- [Step by Step] Postman tool with Microsoft Dataverse Web API
- God Mode - Level Up - Dynamics 365 Chrome Extension
- [Step by Step] Dataverse | Plugins | Using Dependent Assemblies
- Auto generate new GUID for ‘uniqueidentifier’ column in SQL Table
- Associate/Disassociate plugin messages in CRM
- Power Apps - 'Environment Variables' and their usage in Canvas Apps