Search custom fields via API

I’m trying to use the DataService.findByField API call to search Contacts on a custom field, and it returns ERROR: 10 - [NoFieldFound]No field found:

The problem might be that the field name was defined (not by me) with a space in the name; or it may be that I need to do something else. I should mention that I am an outside developer and have not been given Admin rights to the account, so that makes it more difficult to investigate.

Any suggestions would be greatly appreciated. Thanks.

1 Like

Two things. Check the name and make sure it matches the actual database name you can view with the link when you view custom fields. Also when making requests through the api you must precede it with an underscore. You might want to post the code snippet and variable values to make it easier to help.

2 Likes

I would also recommend using DataService.query as you have additional query operators such as “less than” and “greater than” that are not available with findByField.

1 Like

This is the code…$custno is assigned from an input CSV file:
$returnFields = array(‘Id’);
$dups = $app->dsfind(‘Contact’,1,0,‘Customer ID’, $custno, $returnFields);

If I do the exact same code but search on Last Name or another regular field, it works find, but for Customer ID I get:
ERROR: 10 - [NoFieldFound]No field found: Contact.Customer ID
I tried an underscore in front and it didn’t help. I am trying to reach the person who created the custom fields to verify the exact name.

Is there any way to list all the fields in a table from the API? I don’t see it.

Thanks.

1 Like

Goto Admin->settings then General->custom fields and click ‘Go’ then click the “View the field database names link”. This will give you a list of all custom fields and the names used for them that are in the database. This will be the name you must precede with an underscore.

1 Like