问题描述
在CRM 2011中,便会自动创建注释,并在丢失焦点事件时将其附加到主记录中。要求是删除此自动保存功能。只有在打开主窗体之前,用户才可以编辑注释。并且新添加的注释仅在保存主表单后才被保存。例如,如果用户添加一个便笺并关闭浏览器或不保存主表单,则该便笺不应附加到主记录中,而应丢弃新便笺。
In CRM 2011, notes get automatically created and attached to main record on lost focus event. Requirement is to remove this auto save functionality. Only till main form is open user should be able to edit notes. And newly added notes should only get saved once main form is saved. For example, if user add one note and closes the browser or do not save the main form, then that note should not get attached to main record, new note should get discarded.
我在考虑以下解决方案:
I was thinking following solution:
-
创建新的自定义实体TempNotesHolder
create new custom entity TempNotesHolder
与我们要此功能的实体创建1:N关系,例如Case实体
Create 1:N relationship with the entity where we want this functionality, for example Case entity
将实际案例的注释部分设为只读(这是必需的,一旦创建便笺,用户就不想编辑/删除便笺的功能)
Make actual case's note section read only(it is requirement, user don't want to edit/delete functionality for notes once note get created)
编写插件以创建Case事件并创建一个Record用于TempNotesHolder,并将其与case关联(TempNotesHolder中的RegardingId字段= eventId),这将确保一个Case始终只有一个关联的TempNotesHolder记录。 CRM 2011中无法确保一个实体记录在关联实体中只有一个记录,即1:1关系。至少我不知道这样。让我知道是否有人知道它。
Write plugin for create event of Case and create one Record for TempNotesHolder and associate it with case(RegardingId field in TempNotesHolder = incidentId) This will ensure one Case will always have only one associated TempNotesHolder record. There is no way in CRM 2011 to ensure One entity record will have only one record in associated entity i.e. 1:1 relationship. At least I don't know the way. Let me know if any one are aware about it.
在案例表单上,在案例的注释部分下方添加一个IFrame
On Case form, add one IFrame below Case's note section
在案例表单加载事件中,使用fetchXml获取与案例关联的TempNotesHolderId。(Case实体中没有实际字段引用关联的TempNotesHolder,因此需要使用fetchXml。一些如何添加关联的TempNotesHolderId到Case实体,并将该字段放在Case表单上,使其隐藏,以避免fetchXml)
on case form load event, get TempNotesHolderId associated with case using fetchXml.(There is no actual field in Case entity that refer to associated TempNotesHolder, hence need to use fetchXml. Some how we can add associated TempNotesHolderId to Case entity, and place that field on Case form, make it hidden, to avoid fetchXml)
准备url以仅显示TempNotesHolder记录的注释。(/ _controls / notes / notesdata.aspx?EnableInlineEdit = false& EnableInsert = true& id =& ParentEntity =
Prepare url to display only notes of TempNotesHolder record.(/_controls/notes/notesdata.aspx?EnableInlineEdit=false&EnableInsert=true&id=&ParentEntity=
将此网址设置为新添加的IFrame,因此请注意关联的TempNotesHolder中的注释会显示在IFrame中。它还将具有链接添加新注释。
Set this url to newly added IFrame, so notes of associated TempNotesHolder get displayed in IFrame. It will also have link "Add New Note".
用户可以将注释添加到TempNotesHolder中,而不直接添加到Case中记录。
User can add note to TempNotesHolder which are not directly added to Case record.
在Case的pre save事件下,下一步开发插件,并检查是否re是添加到TempNoteHolder的所有注释,如果是,请将这些注释移至案例记录,并删除TempNoteHolderId的注释。这样,便笺将仅在保存主表单时保存到主记录中。
Next develop plugin on pre save event of Case and check if there are any notes added to TempNoteHolder, if yes move those notes to Case record, and delete notes for TempNoteHolderId. This way notes will get saved to main record only on main form save.
要在将少量便笺添加到TempNotesHolder后处理浏览器关闭事件,请在Case pre上编写插件检索事件,检查是否存在与关联的TempNotesHolderId相关的注释,如果存在,则删除这些注释。 (由于便笺出现在TempNotesHolderId上,这意味着由于某些原因这些便笺未移至实际案例记录,并且我们不再需要它们,因此将其删除。这将确保在案例加载时,TempNotesHolder便笺部分始终为空白)
To handle browser close event after adding few notes to TempNotesHolder, write plugin on Case pre Retrieve event, check if any notes present for associated TempNotesHolderId, if present then delete those notes. (As notes are present on TempNotesHolderId, that means due to some reason these notes are not moved to actual case record and we no longer need them, so delete them. This will ensure on case load, TempNotesHolder note section always be blank)
上述解决方案在第8步之前都可以使用。当我尝试在TempNotesHolder中添加注释时,它给了我错误,记录TempNotesHolder中不存在。然后我检查了GUID,当我为TempNotesHolder创建便笺时,我不知道CRM接受了IncidentId。然后,我跟踪了用于创建注释的实际代码,以查找为什么使用IncidentId而不是TempNotesHolderId。我在 _static / _controls / notes / notes.htc函数名称 UpdateNote中找到了以下代码
The above solution was fine till step 8. When I tried to add notes in TempNotesHolder, it gave me error, "Record with does not exists in TempNotesHolder". Then I checked that GUID, I disappointed to know CRM is taking IncidentId when I create note for TempNotesHolder. Then I tracked down the actual code for create notes to find why it is taking IncidentId instead of TempNotesHolderId. I found following code in "_static/_controls/notes/notes.htc" function name "UpdateNote"
xml = 0 + CrmEncodeDecode.CrmXmlEncode(value)+ + _parentCrmFormSubmit.crmFormSubmitId.value + + this.parentEntityType + + CrmEncodeDecode.CrmXmlEncode(currentTitle)+ + this.userId +
xml="0"+CrmEncodeDecode.CrmXmlEncode(value)+""+_parentCrmFormSubmit.crmFormSubmitId.value+""+this.parentEntityType+""+CrmEncodeDecode.CrmXmlEncode(currentTitle)+""+this.userId+""
CRM正在使用_parentCrmFormSubmit在创建便笺时将.crmFormSubmitId.value作为对象ID。
CRM is taking _parentCrmFormSubmit.crmFormSubmitId.value as objectid while creating note.
现在,我坚持这个问题。任何克服此节目停止问题的想法都值得赞赏。也欢迎任何其他替代主要要求的解决方案。
Now I stuck with this problem. Any thoughts to overcome this show stopper issue are appreciated. Also any other alternate solution to main requirement are also welcome.
Pravin Pujari(Microsoft Dynamics CRM 2011开发人员)
Pravin Pujari (Microsoft Dynamics CRM 2011 Developer)
推荐答案
我建议简化解决方案,如下所示:
I would suggest simplifying the solution as follows:
-
在案例中添加字段
Add a field to Case called new_notetext.
针对Case实体上的Pre-Create和Pre-Update消息创建一个插件。
Create a Plugin against the Pre-Create and Pre-Update messages on the Case entity.
在插件中,输入在new_notetext中输入的所有内容,然后使用该文本将注释添加到Case实体。然后清除字段new_notetext,使记录中不保存任何内容。
In the plugin, take anything entered into new_notetext and add a note to the Case entity using that text. Then clear the field new_notetext so nothing is saved with the record.
应该可以正常工作,并且易于实现
Should work just fine and is much simpler to implement.
这篇关于通过在CRM 2011中的表单上添加其他实体的注释来删除注释的自动保存功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!