salesforcejsforce

jsforce search does not work on contact using like operator


my code looks like

const conn = new jsforce.Connection({
oauth2: {
loginUrl: SFDC_LOGIN_URL,
clientId: SFDC_CLIENT_ID,
clientSecret: SFDC_CLIENT_SECRET,
redirectUri: SFDC_REDIRECT_URI,
},
instanceUrl : baseUrl,
accessToken : ACCESS_TOKEN,
refreshToken: REFRESH_TOKEN
});

const resp = await conn.query("SELECT Id,Name,Title,Email,Phone,Department FROM contact WHERE name LIKE 'michael%25' ORDER BY LastModifiedDate DESC LIMIT 10");

this returns now result

if i directly fire this query using postman then i see the data.

if i remove the like part and keep the query to

SELECT Id,Name,Title,Email,Phone,Department FROM contact ORDER BY LastModifiedDate DESC LIMIT 10

then i see the data. So there is some issue with where clause. Plz advise


Solution

  • Try with '%', not '%25'. I think you're urlencoding the '%' and then jsforce does it 2nd time, messing your query up.