As the method name implies... "get" to get information. update() is used to update a record. :) Sorry if there was any indication of misrepresenting what this video is about.
There should be no difference betwen .get() and .query() as ultimately they will do the same query in the database. .get() is more elegant code as you can do "if (incident.get(id))..." rather than .addQuery() then .query() then .next().
@@OneAndOnlyMe the fastest way to retrieve a single record is not mentioned here. If you are looking for performance, do a .query() after a .setLimit(1) followed by a if(next()). Run a background script with and without the setLimit(1) and check the difference. Specially in tables with a lot of data
I have used get before but didn't know it could take two inputs. This is awesome.
Great, I didn't know about two params, its awesome, Next time will use it.
Thanks for sharing Chuck, Lots of love
Cool... two parameters nice feature.... can it be improved to have list of columns and list of their values ?
For the use case of getting specific fields/values, you might want to take a look at GlideQuery.
Thia video is very useful for me because sometimes I forget to add the query() step.. It will work for if only noy for while.Is it?
yes you only get back a single record, so no point in using while.
Well known but you can't use it to update the record
As the method name implies... "get" to get information. update() is used to update a record. :) Sorry if there was any indication of misrepresenting what this video is about.
@@ChuckTomasi
It's all good!
I just wrote it for clarification for others
I've used it in my code.
Shorten up the code Vs Performance. How is the performance of .get() compared to .query() and .next()? Chuck, What do you prefer?
There should be no difference betwen .get() and .query() as ultimately they will do the same query in the database. .get() is more elegant code as you can do "if (incident.get(id))..." rather than .addQuery() then .query() then .next().
@@OneAndOnlyMe the fastest way to retrieve a single record is not mentioned here. If you are looking for performance, do a .query() after a .setLimit(1) followed by a if(next()). Run a background script with and without the setLimit(1) and check the difference. Specially in tables with a lot of data
@@skillz0r10 Having the right indexes configured is also a factor.
Hmm, I posted a comment suggesting people not to use the Get method, and it got deleted.
Really classic ServiceNow..