Communicating between the Client Script and the Server Script of a widget

We’ve had a lot of questions about how the client side and server side of a widget can communicate, so this week I thought it would be a good idea to offer a quick demonstration. In this tutorial we will create a widget that allows the user to add or remove items from a list. In this case it’s just a simple Array, but it could just as easily be using GlideRecord against a table.

Here is the sample code used in the video:


Server Script:

Client Script:


  1. Thanks Nathan for this quick shot. Though, you might want to change places of Client script to server-script and vice-versa.

    Anyways thanks for this.

  2. Thanks, Nathan!!
    I was looking for the server call method implementation from client script and this one is awesome.

  3. Hi,

    If i used data.text = incident.number, its showing blank in the page and if encoded with data.text =’test’+incident.number then its showing in the proper way. Whats the problem in the first case.

    1. Haven’t tested, but maybe it has to be a string. With “test”+incident.number you’re casting it as a string.

  4. Can you elaborate on how input.notes is being used here. Is this Angular magic creating an array based off of data.note?

    1. It’s Service Portal magic. When you call the Server Script from the controller, whatever you pass becomes “input” on the server (usually “data”).

Leave a Reply

Your email address will not be published. Required fields are marked *