最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Hideremove Option set value using JavaScript for CRM Dynamics 365? - Stack Overflow

programmeradmin2浏览0评论

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 i.e. removeopotion/hide.

Im trying to use JavaScript to hide/remove this, however Im very new to JS and dont really understand it, my code is below:

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.

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 i.e. removeopotion/hide.

Im trying to use JavaScript to hide/remove this, however Im very new to JS and dont really understand it, my code is below:

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.

Share Improve this question edited Aug 25, 2021 at 13:59 Arpit 3251 silver badge9 bronze badges asked Aug 25, 2021 at 13:48 The GThe G 831 gold badge1 silver badge12 bronze badges
Add a ment  | 

2 Answers 2

Reset to default 3

You should provide the numeric value in the removeOption method.
As it's said in microsoft docs

formContext.getControl(arg).removeOption(value);
value - Number - The value of the option you want to remove.

I fixed this now thank you guys, was missing the correct schema name name "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);

 }
}
发布评论

评论列表(0)

  1. 暂无评论