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

Community site session details

Session Id :
Small and medium business | Business Central, N...
Suggested answer

How to set a filter with a value containing "&" in Business Central?

(2) ShareShare
ReportReport
Posted on by 67

Hi everyone,

I'm working with Microsoft Dynamics 365 Business Central and I need to set a filter on the industry field where the value is "Oil & Gas" (as a single string). However, when I try to set the filter, Business Central interprets "Oil" and "Gas" as two separate values because of the special character and I get the following error:

"The filter 'Oil & Gas' is not valid for the Industry field on the Customer table. 'Oil' is not an option."

Here is what I'm trying to do:

xValueString := jtoken.AsValue().AsText();  //here xValueString := 'Oil & Gas';
Customer.SetFilter(industry, Format(xValueString));

But it seems like it splits the value into two parts: "Oil" and "Gas", rather than considering them as one value.

Is there a way to properly set this filter so that "Oil & Gas" is treated as a single value, without splitting on the & character?

Any help would be appreciated!

Thanks in advance.

I have the same question (0)
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    19,139 Super User 2025 Season 2 on at
    How to set a filter with a value containing "&" in Business Central?
    Try with this: 
     
    xValueString := 'Oil & Gas';
    Customer.SetFilter(industry, '"%1"', xValueString);
  • Shraddha Jadav Profile Picture
    67 on at
    How to set a filter with a value containing "&" in Business Central?
    @Khushbu Rajvi.
                  xValueString contains a dynamic value. Even if we directly assign the value 'Oil & Gas', it is still treated as a string. However, it splits the value into 'Oil' and 'Gas', resulting in the same error.
  • Suggested answer
    Khushbu Rajvi. Profile Picture
    19,139 Super User 2025 Season 2 on at
    How to set a filter with a value containing "&" in Business Central?
    Have you tried "Oil & Gas"?
    The 'Oil & Gas' value is enclosed in ' ', and I think it should work.
    give it a try and see if it helps.

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Small and medium business | Business Central, NAV, RMS

#1
Rishabh Kanaskar Profile Picture

Rishabh Kanaskar 4,232

#2
Nimsara Jayathilaka. Profile Picture

Nimsara Jayathilaka. 2,863

#3
Sumit Singh Profile Picture

Sumit Singh 2,819

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans