简体   繁体   English

使用 JavaScript 为 CRM Dynamics 365 隐藏/删除选项设置值?

[英]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.

相关问题 Javascript / MS Dynamics CRM 2016:使用确认框更改选项集字段的值 - Javascript / MS Dynamics CRM 2016: Changing value of option set field using confirm box 如何在JavaScript中使用Base64String值设置Dynamics CRM / 365字段 - How to set a Dynamics CRM/365 field with Base64String value in JavaScript 在Dynamics 365 CRM上使用Xrm Object将表单设置为只读 - Set form read only using Xrm Object on Dynamics 365 CRM 使用JavaScript Dynamics CRM设置EntityImage - Set EntityImage Using JavaScript Dynamics CRM Dynamics 365 CRM 插件 - 无法在托管解决方案中设置两个选项字段 NULL - Dynamics 365 CRM Plugin - Unable to set two option field NULL in managed solution 如何在Microsoft dynamics crm 365中通过javascript获取查找字段的值 - How can I get the value of a lookup field by javascript in Microsoft dynamics crm 365 使用javaScript访问Dynamics CRM / 365表单中的其他实体属性 - Accessing Other Entities Attributes in Dynamics CRM/365 Forms with javaScript Dynamics Crm 365 webapi - 通过 javascript 发布网络资源 - Dynamics Crm 365 webapi - publish webresource via javascript Microsoft Dynamics CRM 365通过JavaScript异步调用操作 - Microsoft Dynamics CRM 365 calling an action via JavaScript asynchronously 动态365 crm托管解决方案不覆盖Javascript Web资源 - dynamics 365 crm managed solution not overriding Javascript webresource
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM