document.getElementById('chooseRepresentative').addEventListener('click', function() {
const dialog = new BX.UI.EntitySelector.Dialog({
targetNode: this,
context: 'crm',
enableSearch: true,
dynamicLoad: true,
entities: [{
id: 'company',
options: {
filter: { 'UF_CRM_1682337119': '5279' }
}
}
],
events: {
'Item:onSelect': function(event) {
const selectedItem = event.getData().item;
document.getElementById('representative').value = selectedItem.getTitle();
}
}
});
dialog.show();
});
<button id='companySelectButtonNode'>Select company</button>
<script type="text/javascript">
BX.ready(function(){
const button = document.getElementById('companySelectButtonNode');
let dialog = new BX.UI.EntitySelector.Dialog({
targetNode: button,
context: 'MY_PAGE_CONTEXT',
enableSearch: true,
searchOptions: {
allowCreateItem: false
},
multiple: false,
entities: [
{
id: 'company',
dynamicLoad: true,
dynamicSearch: true
},
],
});
button.addEventListener('click', () => {
dialog.show();
});
});
</script>