web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)
Suggested Answer

Remove option frmo editable grid in D365

(0) ShareShare
ReportReport
Posted on by

Hi

I need to remove on option from the optionset field in editable grid in D365 using javascript or Jquery

Is it possible or not?

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Nagarzuna,

    Please check below reference point number 8 -

    docs.microsoft.com/.../make-grids-lists-editable-custom-control

    You need to write script onload event and remove the options from option set by below way -

    function OnloadOptionSet() {
        var optionSet = Xrm.Page.ui.controls.get("new_myoptionset");
        var optionSetValues = optionSet.getAttribute().getOptions();
        optionSet.clearOptions();
        optionSetValues.forEach(function (element) {
    
            if (element.value == "831260009" || element.value == "831260008")
                optionSet.addOption(element);
    
            if (element.value == "831260008" || element.value == "831260008")
                optionSet.addOption(element);
    
        });
    }


    Hope this helps.

  • Community Member Profile Picture
    on at

    Hi Goutam,

    Thanks for the reply.

    But i'm working on home grid editables. so i need to remove ONE OPTION whenever i clicked on that column regardless of the condition. it should always to be removed.

    i can remove that option by going to entity customisztions, but it should be visible for existing records.

    how can we configure the javascript onload of home grid other than 1.record selection, 2.onchange, 3.onsave ?

    in below screen, the option Item3 should always be not visible when we click on that column to change.

    7848.Untitled.png

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    Hi Nagarjuna,

    I have not tried yet ,could you please check the URL I have shared this is for both main and subgrid  , there is an event TAB , where you can registered your java script "OneRecordSelect" event.

    Hope this works.

    0488.editablegrid.png

  • Community Member Profile Picture
    on at

    Sure Goutam,

    Thanks for quick reply.

  • Shiva K Profile Picture
    40 on at

    Hi Goutam,

    Did you found solution? to remove or Clear Options from Option Set in Editable Grid?

    Am also in same boat what to clear some options on Row Select Event.  :(

    Regards,

    Shiva K

  • gdas Profile Picture
    50,091 Moderator on at

    Hello Shiva ,

    I have tried but its not working , I have posted it in  another thread . You can follow the thread .

    community.dynamics.com/.../279872

  • Suggested answer
    Community Member Profile Picture
    on at

    Hi All, 

    Since remove option from the option set field in editable grid is not available yet, We can go with another alternative like we can prevents user to select option and if user select same option then we can show ERROR notification message and prevent to save same record, Need to registered java script function on change event of the option set field.

    Please refer below screen:

    editableGrid_5F00_Test.png

    Thanks,

    Mayank Raval

    If found useful, please mark the answer as verified

  • yleclerc Profile Picture
    1,549 on at

    @Mayank Raval: Could you share your code? I tried to replicate it with my custom field but I get an error. JS validators send an error at line 24 - actions: [actionCollection]

    function preventOption(executionContext)

    {

    debugger;

    var executionEntity = (executionContext.getFormContext().data.entity);

    var statutField = executionEntity.attributes.getByName("new_statutdelatache");

    var statutValue = statutField.getValue();

    var field = statutField.controls.getByIndex(0);

    if(statutValue == 100000005 || statutValue == 100000008)

    {

    var actionCollection =

    {

    //message: 'Vous ne pouvez pas sélectionner cette valeur directement. Ces valeurs sont assignées via workflow seulement.'

    actions: null

    };

    actionCollection.actions = [function () {

    field.clearNotification('1');

    }];

    field.addNotification({

    messages: ['Vous ne pouvez pas sélectionner cette valeur directement. Ces valeurs sont assignées via workflow seulement.'],

    notificationLevel: 'ERROR',

    uniqueId: '1'

    actions: [actionCollection]

    });

    return false;

    }

    else

    {

    field.clearNotification(1);

    }

    }

  • yleclerc Profile Picture
    1,549 on at

    This code finally worked:

    function preventOption(executionContext) {

       var executionEntity = (executionContext.getFormContext().data.entity);

       var statutField = executionEntity.attributes.getByName("new_statutdelatache");

       var statutValue = statutField.getValue();

       var field = statutField.controls.getByIndex(0);

       if (statutValue === 100000005 || statutValue === 100000008) {

           var actionCollection =

                   {

                       //message: 'Vous ne pouvez pas sélectionner cette valeur directement. Ces valeurs sont assignées via workflow seulement.'

                       actions: null

                   };

           actionCollection.actions = [function () {

               field.clearNotification('1');

           }];

           field.addNotification({

               messages: ['Vous ne pouvez pas sélectionner cette valeur directement. Ces valeurs sont assignées via workflow seulement.'],

               notificationLevel: 'ERROR',

               uniqueId: '1'

           }

               );

           actions[actionCollection];

           return false;

       }

       else {

               field.clearNotification(1);

           }

    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Varsha deshpande Profile Picture

Varsha deshpande 5

#2
NeerajPawar Profile Picture

NeerajPawar 2

#2
jlattimer Profile Picture

jlattimer 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans