Change ‘Lookup For’ in Party list Using JavaScript
Introduction: Party list like “TO” usually contain record of type Accounts, Contacts, Knowledge Articles, Leads, Users

If you want to restrict the Lookup values, write the below script on load on the form and also on change of the partly list
var lookup = {
dropdown: function (execContext) {
var formContext = execContext.getFormContext();
if (formContext.getAttribute("dropdown").getValue() != null) {
dropdown = formContext.getAttribute("dropdown").getValue();
var LookUpFor = ['account'];
var fieldlist = ['to','cc','bcc'];
fieldlist.forEach(
function (item, index) {
formContext.getAttribute(item).setValue(null);
formContext.getControl(item).setEntityTypes(LookUpFor);
});
}
}}
Here for each value in fieldlist, the lookup for will be set to account. This is not applicable to “FROM” as it has OOB restrictions.
Related posts:

Resolving SSL/TLS Secure Channel Trust Errors in Dynamics 365 Finance and Operations

How to change a Bill of material (BOM) item on a production order
![Shopify Meets Dynamics 365 Finance and Operations: A Guide to Integration [Part 2]](https://www.cloudfronts.in/wp-content/uploads/2024/12/DALL·E-2024-12-14-12.29.44-A-professional-illustration-depicting-the-integration-between-Shopify-and-Dynamics-365-Finance-and-Operations.-The-image-shows-Shopify-on-one-side-wit-150x150.webp)
Shopify Meets Dynamics 365 Finance and Operations: A Guide to Integration [Part 2]
![Shopify Meets Dynamics 365 Finance and Operations: A Guide to Integration [Part 1]](https://www.cloudfronts.in/wp-content/uploads/2024/12/DALL·E-2024-12-14-12.29.44-A-professional-illustration-depicting-the-integration-between-Shopify-and-Dynamics-365-Finance-and-Operations.-The-image-shows-Shopify-on-one-side-wit-150x150.webp)
