I'm trying to remove some options from an optionSet inside the BPF, but it doesn't work. It only works for fields inside the form.
function cargarRazonesDevolucion(executionContext) { const form = executionContext.getFormContext(); const headerControl = form.getControl('header_process_ao_razon_devolucion_seleccion'); if (!headerControl) return; const control = form.getAttribute('ao_razon_devolucion_seleccion'); const options = control.getOptions(); console.log("OPTIONS", options); let caseType = form.getControl('ao_tipo_caso').getAttribute().getValue()[0].name; console.log("CASETYPE", caseType); options.forEach(item => { if (caseType == 'SOLICITUD' && item.text.includes('reclamo')) { headerControl.removeOption(item.value); } else if (caseType == 'RECLAMACION' && item.text.includes('solicitud')) { headerControl.removeOption(item.value); } }); }
Hi,
Can you try removing custom control configuration for this field and see if it works. This way we can say that it is not working when we add custom control to the field.
BTW are you using your own custom control or OOB custom control provided by microsoft?
Hi Aneudys,
I have tested the code, it can work for BPF.
function cargarRazonesDevolucion(executionContext) { const form = executionContext.getFormContext(); const headerControl = form.getControl('header_process_purchasetimeframe'); if (!headerControl) return; headerControl.removeOption(1); }
Before:
After:
So you can check that the Name of field that you want to modify and the value that you want to remove from the option set Whether is correct. Or you can debug your JS code to find why it can not work.
Regards,
Clofly
Hello. Thanks for your answer.
I tried exactly the same way you did, but it doesn't work.
BTW the condition works well and it reaches to execute the removeOption function but Idk if it fails because of custom controls.
function cargarRazonesDevolucion(executionContext) { const form = executionContext.getFormContext(); const headerControl = form.getControl('header_process_ao_razon_devolucion_seleccion'); if (!headerControl) return; headerControl.removeOption(100000000); }
Hi,
I have just tried below code on Lead for OOB Lead Source field and it worked.
function cargarRazonesDevolucion(executionContext) {
const form = executionContext.getFormContext();
const headerControl = form.getControl('header_process_leadsourcecode');
if (!headerControl)
return;
headerControl.removeOption(930720003);
}
Please check below conditions in your code. Add alert inside condition and see it it is going inside.
I suspect there is something wrong with the condition.
if (caseType == 'SOLICITUD' && item.text.includes('reclamo')) {
headerControl.removeOption(item.value);
} else if (caseType == 'RECLAMACION' && item.text.includes('solicitud')) {
headerControl.removeOption(item.value);
}
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,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156