# Get company with "&" in name

**URL:** <https://forum.mautic.org/t/get-company-with-in-name/21638>\
**Category:** Development\
**Created:** [November 16, 2021, 3:50pm UTC](https://forum.mautic.org/t/get-company-with-in-name/21638 "2021-11-16T15:50:04Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![stef000](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/stef000/32/690_2.png) [@stef000](https://forum.mautic.org/u/stef000)\
**Post date:** [November 16, 2021, 3:50pm UTC](https://forum.mautic.org/t/get-company-with-in-name/21638/1 "2021-11-16T15:50:04Z")

</div>

Hi,

I am trying to get a specific company which has an ampersand in its name. The reqeust is being sent with mautic api-library to the companies endpoint with a custom query which looks something like this:

$qb = new QueryBuilder();  
$qb-\>setSelect(“SELECT \* FROM companies”);  
$qb-\>addWhere($qb-\>expr()-\>eq(‘companyname’, “MY COMPANY & NAME”));

This works as intended as long as there is no ampsersand in the company name. The URL for the query gets encoded like this but does not return any matches even though it should:

select=SELECT+%2A+FROM+companies&where%5B0%5D%5Bcol%5D=companyname&where%5B0%5D%5Bexpr%5D=eq&where%5B0%5D%5Bval%5D=MY+COMPANY+%26+NAME&limit=1000000000000000000

Is there any way to find a company with “&” in its name?

---

<div class="post-metadata">

**Author:** ![ilo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ilo/32/1181_2.png) [@ilo](https://forum.mautic.org/u/ilo)\
**Post date:** [October 1, 2023, 12:00pm UTC](https://forum.mautic.org/t/get-company-with-in-name/21638/2 "2023-10-01T12:00:56Z")

</div>

Hi,  
This issue seems to be still present, did you find any solution? Thanks!

---

<div class="post-metadata">

**Author:** ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)\
**Post date:** [October 1, 2023, 12:35pm UTC](https://forum.mautic.org/t/get-company-with-in-name/21638/3 "2023-10-01T12:35:52Z")

</div>

Can you post a complete code you are using to interact with mautic api? Thanks.  
Regards, M.

---

<div class="post-metadata">

**Author:** ![ilo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ilo/32/1181_2.png) [@ilo](https://forum.mautic.org/u/ilo)\
**Post date:** [October 2, 2023, 6:05am UTC](https://forum.mautic.org/t/get-company-with-in-name/21638/4 "2023-10-02T06:05:30Z")

</div>

Hello,  
I am using curl.  
First, I replace spaces with %20 in the name of the company.  
I also tried to replace & with %26, but with no success. As long as the name doesn’t contain “&” it works perfectly.

Below is the URL:

$reqUrlCompany = “https://” . $loginname . “:” . $password . “@” . $siteurl . “/api/companies?where%5B0%5D%5Bcol%5D=companyname&where%5B0%5D%5Bexpr%5D=eq&where%5B0%5D%5Bval%5D=” . $companyname;

---

<div class="post-metadata">

**Author:** ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)\
**Post date:** [October 2, 2023, 6:35am UTC](https://forum.mautic.org/t/get-company-with-in-name/21638/5 "2023-10-02T06:35:46Z")

</div>

Where in the docs do you see, you can pass queryBuilder as param in url.

Also there are functions to encode url properly (in basically every programming language), you do not need to replace it manually.

Regards, M.

---

<div class="post-metadata">

**Author:** ![ilo](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/ilo/32/1181_2.png) [@ilo](https://forum.mautic.org/u/ilo)\
**Post date:** [October 2, 2023, 6:50am UTC](https://forum.mautic.org/t/get-company-with-in-name/21638/6 "2023-10-02T06:50:41Z")

</div>

[Mautic Developer Documentation](https://developer.mautic.org/#list-contacts) → Advanced filtering section

---

<div class="post-metadata">

**Author:** ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)\
**Post date:** [October 2, 2023, 7:32am UTC](https://forum.mautic.org/t/get-company-with-in-name/21638/7 "2023-10-02T07:32:55Z")

</div>

Hi, I have tested this, it looks like a bug to me, can you please report it on Github?

Further more might I suggest using something like vatid to filter the results. It seems more robust way of doing this.

In any case the bug should be reported and fixed in future versions of mautic.

Regards, M.

---

<div class="post-metadata">

**Author:** ![joeyk](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/joeyk/32/11164_2.png) [@joeyk](https://forum.mautic.org/u/joeyk)\
**Post date:** [October 2, 2023, 11:01am UTC](https://forum.mautic.org/t/get-company-with-in-name/21638/8 "2023-10-02T11:01:48Z")

</div>

Hi,  
Deja Vu:

> <https://github.com/mautic/mautic/issues/11445>
>
> \### Mautic Version
> 
> 4.4.x series
> 
> \### PHP version
> 
> 7.4.28
> 
> \### What browsers are… you seeing the problem on?
> 
> Chrome
> 
> \### What happened?
> 
> If you have a company with an ampersand in it's name, like "AT&T", then you can't associate contacts with the company.
> 
> \### How can we reproduce this issue?
> 
> Step 1: Create or edit a company so it has an ampersand in it's name.
> Step 2: Edit a contact and attempt to associate it with the company in step 1.
> Step 3: It won't associate and the browser console will show an error.
> 
> \### Relevant log output
> 
> \`\`\`shell
> libraries.js?v7b9ed0ae:1906 Uncaught TypeError: Cannot set properties of undefined (setting 'selected')
> at Chosen.result\_select (libraries.js?v7b9ed0ae:1906:177)
> at Chosen.search\_results\_mouseup (libraries.js?v7b9ed0ae:1901:626)
> at HTMLUListElement.\<anonymous\> (libraries.js?v7b9ed0ae:1886:1000)
> at HTMLUListElement.dispatch (libraries.js?v7b9ed0ae:465:447)
> at elemData.handle (libraries.js?v7b9ed0ae:451:166)
> \`\`\`
> 
> 
> \### Code of Conduct
> 
> \- \[X\] I confirm that I have read and agree to follow this project's Code of Conduct

and

> <https://github.com/mautic/mautic/issues/11802>
>
> \### Mautic Version
> 
> 4.4.x series
> 
> \### PHP version
> 
> 7.4.33
> 
> \### What browsers are… you seeing the problem on?
> 
> Not relevant
> 
> \### What happened?
> 
> When you search for a company name in contact and the company name has a '&' in the name it does not find the company:
> 
> Example: W&G Ltd
> 
> Believe it's the '&' coursing the issue, it works in the company lists, but not when searching inside a contact to add to the company name.
> 
> \### How can we reproduce this issue?
> 
> Step 1: Create a company called 'W&G Ltd'
> Step 2: Create a contact, now search for that company name inside the contact. With over 2000 company names, we have to search for them, by starting to type the name in the company box.
> 
> \### Relevant log output
> 
> \_No response\_
> 
> \### Code of Conduct
> 
> \- \[X\] I confirm that I have read and agree to follow this project's Code of Conduct

---

<div class="post-metadata">

**Author:** ![mzagmajster](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.mautic.org/mzagmajster/32/687_2.png) [@mzagmajster](https://forum.mautic.org/u/mzagmajster)\
**Post date:** [October 2, 2023, 11:18am UTC](https://forum.mautic.org/t/get-company-with-in-name/21638/9 "2023-10-02T11:18:04Z")

</div>

The issue is closed, but its not solved. I have tested on Mautic 4.4.6
