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
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);
}
}
@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);
}
}
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:
Thanks,
Mayank Raval
If found useful, please mark the answer as verified
Hello Shiva ,
I have tried but its not working , I have posted it in another thread . You can follow the thread .
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
Sure Goutam,
Thanks for quick reply.
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.
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.
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.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156