How to use GlideAjax and Client Scripts with Best Practice in mind

How to use GlideAjax and Client Scripts with Best Practice in mind

I've seen a couple of questions in the community about how to get more data from the server when you write a Client Script. What comes in mind is everything from GlideRecord calls, use of getReference method to GlideAjax and g_scratchpad method.

 I made a video with having best practice in mind and that would rule out both the GlideRecord call and the getReference. I also show how to avoid another server call when you do a setValue on a reference field which is pretty common to do if your mind might be somewhere else when you write the code.

Here is a link to the video and dont forget to subscribe ;) YouTube Video

And you want an update set with the code that is used in the video, you can find it here:https://github.com/goranlundqvist/Update-sets#glideajax-example?

//G?ran?

Chris Sanford

Service Delivery Manager & Senior Architect at GlideFast Consulting

4 å¹´

Top Tanti looks like you were right, getReference is bad! Definitely something I'll keep in mind in the future.

G?ran Lundqvist - ServiceNow Witch Doctor

Expert Training Programs - Principal Delivery Manager | ServiceNow MVP[2017 - 2021] | Author

7 å¹´

Updated with a link to an update set with both the client script and Script Include: https://github.com/goranlundqvist/Update-sets#glideajax-example

Ian Mildon

HCS Application Systems Analyst Senior at UNC Health

7 å¹´

As for the reference field issue, use g_form.getDisplayBox('<ref field>').value to return the value and not the sys_id.

赞
回复
Michael Herron

ServiceNow Master Architect/Delivery Manager

7 å¹´

Robert Bryan getReference is bad :p

Nice keep them coming

要查看或添加评论,请登录

G?ran Lundqvist - ServiceNow Witch Doctor的更多文章

  • AI Agent Orchestrator in ServiceNow: Transforming Enterprise Automation

    AI Agent Orchestrator in ServiceNow: Transforming Enterprise Automation

    Disclaimer: This article is written by me personally and reflects my own perspectives. It is not an official statement…

  • The Future of AI in ServiceNow: Smarter Workflows, Faster Decisions

    The Future of AI in ServiceNow: Smarter Workflows, Faster Decisions

    Disclaimer: This article is written by me personally and reflects my own perspectives. It is not an official statement…

    15 条评论
  • Unlocking the Power of Role-Based Access Control (RBAC) in ServiceNow

    Unlocking the Power of Role-Based Access Control (RBAC) in ServiceNow

    Unlocking the Power of Role-Based Access Control (RBAC) in ServiceNow Introduction Did you know that mismanaged access…

    4 条评论
  • The joy of getTime() & getByFormat()

    The joy of getTime() & getByFormat()

    I looked at the result I got "*** Script: [DEBUG] 06:00:00" and then I looked at the code: var gdt = new…

    11 条评论
  • How to create external search source "Search Chuck" in ServiceNow

    How to create external search source "Search Chuck" in ServiceNow

    Earlier this week I took the Service Portal Fundamentals class so I could get my voucher for the Micro-cert. Even if…

    4 条评论
  • How to get the fulfillers attention with connect

    How to get the fulfillers attention with connect

    Had a hard time coming up with a good headline for this article. But at least I got your attention.

    7 条评论
  • Client script be gone! Here comes UI Policy!

    Client script be gone! Here comes UI Policy!

    It almost passed my eyes, but luckily Philip made me aware of it in one of my other posts about not using DOM…

    11 条评论
  • SLA Breakdown

    SLA Breakdown

    There are so much new things in London, both big and small stuff. It seems like there just isn't enough time to show it…

    7 条评论
  • Journey into Virtual Agent - Part 2

    Journey into Virtual Agent - Part 2

    Here comes the followup video that I promised when doing Virtual Agent setup in ServiceNow Part 1. This time we go a…

    6 条评论
  • Show reports in Service Portal? Easy peasy

    Show reports in Service Portal? Easy peasy

    Many people have asked for an easy way to publish reports within the Service Portal. And there answer has actually been…

    25 条评论

社区洞察

其他会员也浏览了