我需要在帐户记录表单上创建一个新的自定义按钮。单击时,它应该打开约会实体的快速创建表单。 我还想在加载时隐藏预约表单中的某些字段。下面写的代码。
/*Function to open the Quick Create Form*/
function OpenQuickCreateForm(primaryControl) {
var entityFormOptions = {};
entityFormOptions["entityName"] = "appointment";
entityFormOptions["useQuickCreateForm"] = true;
var formParameters = {};
// Open the quick create form.
Xrm.Navigation.openForm(entityFormOptions, formParameters).then(
function(success) {
appointmentsetFieldsOnLoad(primaryControl);
},
function(error) {
console.log(error);
});
}
/*Function to hide the fields onload of Appointment Quick Create Form*/
function appointmentsetFieldsOnLoad(primaryControl) {
var formContext = primaryControl;
formContext.getControl("requiredattendees").setVisible(false);
}
上面的代码给出了错误。
同样的快速创建表单也可以从其他位置打开,但我不希望在那里进行这些更改。 仅当我通过单击自定义按钮创建约会时才应设置这些字段。
我可以在单击按钮时打开 QC 表单,但主要控件正在传递帐户的上下文,因此我的代码无法设置约会字段。 如果我在加载表单时编写代码,那么它将适用于所有表单;
UCI有什么方法可以识别表单是通过按钮点击还是其他地方(时间轴)打开的。
您能否建议我如何满足此要求?
如有任何帮助,我们将不胜感激。
注意:我没有积分在帖子中添加照片以显示调试屏幕。
为此,您可以在约会实体的快速创建表单 onload JS 代码上编写单独的代码,并在约会实体中创建一个 bool 字段,当弹出快速创建表单时,将该 boolField 设置为 true 并基于您可以轻松地识别该布尔字段从加载此快速创建表单的位置。 希望这会对您有所帮助。
致以诚挚的问候。