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

Notifications

Announcements

No record found.

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 111

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
    20,971 Super User 2025 Season 2 on at
    Try with this: 
     
    xValueString := 'Oil & Gas';
    Customer.SetFilter(industry, '"%1"', xValueString);
  • Shraddha Jadav Profile Picture
    111 on at
    @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
    20,971 Super User 2025 Season 2 on at
    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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

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

#1
OussamaSabbouh Profile Picture

OussamaSabbouh 2,116

#2
Khushbu Rajvi. Profile Picture

Khushbu Rajvi. 764 Super User 2025 Season 2

#3
YUN ZHU Profile Picture

YUN ZHU 635 Super User 2025 Season 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans