[英]Hide/remove Option set value using JavaScript for CRM Dynamics 365?
working on a tutorial at home with Microsoft Dynamics 365 CRM, to hide a Option Set Value from a dropdown, however this dropdown also is used on a Business Process Flow, I dont want to delete the Option Set Value, just hide it ie removeopotion/hide.在家中使用 Microsoft Dynamics 365 CRM 编写教程,以从下拉列表中隐藏选项设置值,但是此下拉列表也用于业务流程,我不想删除选项设置值,只是将其隐藏即 removeoption/隐藏。
Im trying to use JavaScript to hide/remove this, however Im very new to JS and dont really understand it, my code is below:我正在尝试使用 JavaScript 来隐藏/删除它,但是我对 JS 很陌生并且不太了解它,我的代码如下:
function hideOptions(executionContext) {
var formContext = executionContext.getFormContext();
if (formContext.ui.getFormType() == 1 || formContext.ui.getFormType() == 2 ) {
var pickList = formContext.Page.getControl("statuscode");
pickList.removeOption("Test1");
pickList.removeOption("Test2");
pickList.removeOption("Test3");
pickList.removeOption("Test4");
}
}
Please advise.请指教。
You should provide the numeric value in the removeOption
method.您应该在
removeOption
方法中提供数值。
As it's said in microsoft docs正如微软文档中所说
formContext.getControl(arg).removeOption(value);
formContext.getControl(arg).removeOption(value);
value - Number - The value of the option you want to remove.value - Number - 要删除的选项的值。
I fixed this now thank you guys, was missing the correct schema name name "header_statuscode"
我现在解决了这个问题,谢谢你们,缺少正确的模式名称名称
"header_statuscode"
function hideOptions(executionContext) {
var formContext = executionContext.getFormContext();
if (formContext.ui.getFormType() == 1 || formContext.ui.getFormType() == 2 ) {
var pickList = formContext.getControl("header_statuscode");
pickList.removeOption(1);
pickList.removeOption(2);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.