简体   繁体   English

Dynamics CRM Form OnLoad事件-在Form或OnLoad事件中调用函数

[英]Dynamics CRM Form OnLoad Event - Call functions in Form or in OnLoad Event

I've taken over from another Dynamics CRM developer and noticed that they have a JS script file as a form library. 我已经从另一位Dynamics CRM开发人员那里接手了,发现他们有一个JS脚本文件作为表单库。 They have then registered multiple functions from the script library with the Form's OnLoad event using the Form Properties window. 然后,他们使用“表单属性”窗口通过“表单的OnLoad”事件从脚本库中注册了多个功能。 The same could have been achieved by calling an onLoad function in the script file and calling those other functions inside the onLoad function. 通过在脚本文件中调用onLoad函数并在onLoad函数内部调用其他函数,可以实现相同的目的。 They both are the same but I wanted to know if anyone can think of reasons why one method is better than the other or viceversa? 两者相同,但是我想知道是否有人能想到为什么一种方法优于另一种方法的原因,反之亦然?

Thanks. 谢谢。

This is a subjective decision, I'm not sure one is really better than the other. 这是一个主观决定,我不确定哪一个真的比另一个更好。

Having a single on load function that calls all other functions has a nice simplicity, and enables control via code. 拥有一个调用所有其他功能的加载功能非常简单,并且可以通过代码进行控制。

Registering the functions individually has a few additional benefits: 单独注册功能还有一些其他好处:

  • Gives a clear visibility via the form properties window of what is registered on load. 通过表单属性窗口可以清楚地看到已加载的内容。 This could be especially helpful to non-coders. 这对于非编码人员可能特别有帮助。
  • If the JavaScript file was a shared file used across multiple forms, this allows someone to 'pick' parts of a file. 如果JavaScript文件是跨多种格式使用的共享文件,则允许某人“拾取”文件的各个部分。
  • Allows individual functions to be registered and unregistered easily without having to change the code. 无需更改代码即可轻松注册和注销各个功能。 This could be helpful for debugging issues or working on items in isolation. 这可能有助于调试问题或单独处理项目。

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

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