dynamics crm - Set and get Notes field in CRM 2011 Javascript - Stack Overflow

I need to set the Notes field to the Notes field value in other entity in CRM 2011 form. So, I need to

I need to set the Notes field to the Notes field value in other entity in CRM 2011 form. So, I need to know how get and set the Notes field using Javascript. And I'm not able to get the name of Notes field inside the section as you can seen in the below image.

I need to set the Notes field to the Notes field value in other entity in CRM 2011 form. So, I need to know how get and set the Notes field using Javascript. And I'm not able to get the name of Notes field inside the section as you can seen in the below image.

Share Improve this question edited May 21, 2012 at 22:53 Peter Majeed 5,3722 gold badges35 silver badges58 bronze badges asked May 21, 2012 at 11:00 Charan Raju C RCharan Raju C R 7685 gold badges22 silver badges43 bronze badges 4
  • Note field on which entity? Or are you trying to get values from a field on the Note entity? – Greg Owens Commented May 21, 2012 at 11:15
  • From any entities except Notes, say some custom entity.. – Charan Raju C R Commented May 21, 2012 at 11:25
  • Why do you need the name of the notes ponent? If you want to create notes, shouldn't you just be using something like bizforward.cws-international./2011/01/26/… ? By default the notes ponent renders as an iFrame called 'notescontrol'. – glosrob Commented May 21, 2012 at 12:08
  • Yes, just now I got to know the name as 'notescontrol'. I thought of getting the Notes tab value by name. As its not an attribute, I could not get it. Just I need the description inside the Note Tab.. – Charan Raju C R Commented May 21, 2012 at 12:19
Add a ment  | 

3 Answers 3

Reset to default 2

OK there are two approaches required here.

@Philip_Rich pointed out that annotations for existing records are created as soon as they lose focus and can therefore be queried. You should be able to find existing code for this quite easily (if not, ask here).

You yourself acknowledged that for new (unsaved) records, annotations are not saved until after the parent record is saved. There is no supported way to access the value in the notes field at this point, however this nasty bit of code should get the value you seek. Beware that since it is unsupported, it is vulnerable to DOM changes in the forms:

var myNotesText = document.getElementById("notescontrol").contentWindow.document.getElementById("NotesTable").children[1].children[4].children[0].innerText;

Notes in CRM are called 'annotations' under the hood. You create an annotation as you would any other CRM record type and then associate that annotation with the entity record of interest. I haven't attempted to retrieve notes fields from javascript explicitly (I've normally done this via a plug-in, which is documented in the SDK). However, I see no reason why you couldn't perform an oData query to retrieve annotations where the associated entity record was of entity type X for example.

In JS you don't need to do assign, you just create a note.

But you definetely need a created entity before you can attach a note to it.

Notes can be two types a note and an attachment.

Here is the example of how you can create a simple (text) note (annotation) from JS.

function _createAnnotation(entity, subject, text) {
    var orgService = GetOrganizationService();
    var annotation = {};
    annotation.Name = "annotation";
    annotation._properties = [];
    annotation._propertyTypes = [];
    annotation._properties['objectid'] = entity;
    annotation._propertyTypes['objectid'] = 'lookup';
    annotation._properties['subject'] = subject;
    annotation._propertyTypes['subject'] = 'string';
    annotation._properties['notetext'] = text;
    annotation._propertyTypes['notetext'] = 'string';
    annotation._properties['isdocument'] = 'false';
    annotation._propertyTypes['isdocument'] = 'boolean';
    annotation._properties['mimetype'] = 'text/html';
    annotation._propertyTypes['mimetype'] = 'string';
    orgService.Create(annotation);
}

Where:

entity - (EntityReference) of the entity you want to attach a note to.

subject - (String) Subject of a note.

text - (String) Body of a note.

If you want to attach an MS office document then you need to change isdocument and mimetype parameters.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744399613a4572320.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信