GlideRecord get - Did You Know

Поделиться
HTML-код
  • Опубликовано: 27 окт 2024
  • Pass one or two parameters to get a record by sys_id or any other field/value pair quickly and easily. #servicenowdyk

Комментарии • 15

  • @rayroulstone3565
    @rayroulstone3565 Год назад +1

    I have used get before but didn't know it could take two inputs. This is awesome.

  • @SteemanCodes
    @SteemanCodes Год назад

    Great, I didn't know about two params, its awesome, Next time will use it.
    Thanks for sharing Chuck, Lots of love

  • @vemulakondasubramanyam3747
    @vemulakondasubramanyam3747 Год назад +2

    Cool... two parameters nice feature.... can it be improved to have list of columns and list of their values ?

    • @ChuckTomasi
      @ChuckTomasi Год назад

      For the use case of getting specific fields/values, you might want to take a look at GlideQuery.

  • @samikshasaloni5913
    @samikshasaloni5913 Год назад

    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?

    • @justinjoy1701
      @justinjoy1701 Год назад +2

      yes you only get back a single record, so no point in using while.

  • @aviramran157
    @aviramran157 Год назад +1

    Well known but you can't use it to update the record

    • @ChuckTomasi
      @ChuckTomasi Год назад

      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.

    • @aviramran157
      @aviramran157 Год назад

      ​@@ChuckTomasi
      It's all good!
      I just wrote it for clarification for others

  • @vibhamadaan
    @vibhamadaan Год назад

    I've used it in my code.

  • @fung5768
    @fung5768 Год назад

    Hmm, I posted a comment suggesting people not to use the Get method, and it got deleted.
    Really classic ServiceNow..

  • @vkachineni
    @vkachineni Год назад +1

    Shorten up the code Vs Performance. How is the performance of .get() compared to .query() and .next()? Chuck, What do you prefer?

    • @OneAndOnlyMe
      @OneAndOnlyMe Год назад

      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().

    • @skillz0r10
      @skillz0r10 Год назад

      @@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

    • @OneAndOnlyMe
      @OneAndOnlyMe Год назад +1

      @@skillz0r10 Having the right indexes configured is also a factor.