简体   繁体   English

MS Dynamics CRM-如何测试帐户中是否存在Notes记录

[英]MS Dynamics CRM - how to test for presence of Notes records within Accounts

I need to check (OnLoad) whether an Account has Notes added to it. 我需要检查(OnLoad)帐户是否已添加便笺。 I've tried doing this using workflows but that only tests after a Note is added rather than if they are already there ie On Change, On updating, On status change etc. 我尝试使用工作流进行此操作,但是仅在添加便笺后进行测试,而不是如果它们已经存在时进行测试,即“更改时”,“更新时”,“状态更改”等。

Also tried accessing Notes via JavaScript but seems to not be able to reach the attribute. 还尝试通过JavaScript访问Notes,但似乎无法访问该属性。 Will paste JScript here if this will help, though that might be the wrong way to go anyway. 如果有帮助,将在此处粘贴JScript,尽管这可能是错误的方法。

function NotesAlert() {

 // the 'notestext' field is the Notes description area

  var NotesDesc = Xrm.Page.getAttribute("notestext").getValue();

  if(NotesDesc !=null) {
     Xrm.Page.getAttribute("dt_legacyuserurn").setValue("Notes exist for 
     this Acc");
  }
}

Whether it is client side (JavaScript) or server side (C# plugins, workflows), you have to query the associated notes (annotations) for that particular account record & do the validation. 无论是客户端 (JavaScript)还是服务器端 (C#插件,工作流程),您都必须查询关联的注释(注释)以获取特定的帐户记录并进行验证。

If you want to validate it in JS, use web api to get the associated notes of account from onLoad & onSave Form events, even onChange of fields can be done like below. 如果要在JS中对其进行验证,请使用Web API从onLoadonSave Form事件获取相关的帐户 onSave ,即使字段的onChange也可以按以下方式进行。

var query = "/api/data/v8.2/annotations?$filter=_objectid_value eq" + accountId;

If you want to validate in Plugins/Workflows (custom), use fetchxml or query expression to query the associated notes of account from Create, Update messages. 如果要在“插件/工作流”(自定义)中进行验证,请使用fetchxml查询表达式从“创建,更新”消息中查询帐户的关联便笺

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM