0

I'm trying to filter my users list by comparing two parameters

query="EmployeeData.EmployeeID=externalId"

EmployeeData.EmployeeID is a custom schema that is populated, with a cron job, with the same value as externalId.

Of course I let the cron do the field copy only if necessary, this is the reason I'm trying to filtering the users list.

In the way i wrote seems that the query trying to looking for a value "externalId" into the EmployeeData.EmployeeID ignoring that "externalId" is a even a field

any suggestion?

Ryuk Ryuk
  • 23
  • 5
  • Ryuk Ryuk: Where are you trying to run the query from? Is it from a Google Apps Script? – carlesgg97 Oct 07 '19 at 10:38
  • In this case, yes, I tried to do it from Google Apps Script but as I understood from Google, right now the Admin SDK is totally replicated into Google Apps Script without restriction. Because of this I think that this field could be used in both, Google Apps Script and GCF (for example) the same way. – Ryuk Ryuk Oct 08 '19 at 11:51

1 Answers1

0

The way your code is written, the query sent to Google's servers is as you correctly guessed the following: EmployeeData.EmployeeID=externalId where your actual externalId is not sent but rather the string "externalId".

To replace this string for the actual value of your variable, you can use what is called "string concatenation" 1. To do it, you just need to modify your code as shown below:

query="EmployeeData.EmployeeID=" + externalId;

This way, the query will be sent as you need to Google's servers.

carlesgg97
  • 4,184
  • 1
  • 8
  • 24
  • Thank you for your time. I think that could be work in case you are looking for one specific person. Am I wrong? What I'm looking for is a query that could be used as a "where" condition in SQL. Think about it as something like "extract all the users that has a mismatch between EmployeeID and externalID". – Ryuk Ryuk Oct 10 '19 at 09:02
  • @RyukRyuk Thanks for providing more information, I think I understand your question now. May I ask you, what kind of attribute is 'externalId'? Is it a custom attribute too? See how a user is internally defined here for reference: https://developers.google.com/admin-sdk/directory/v1/reference/users#resource – carlesgg97 Oct 10 '19 at 10:45
  • so sorry for the late reply, i lost the notification. Yes that's a standard attribute (externalIds) – Ryuk Ryuk Jan 05 '20 at 13:37