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. Can you help how to updated all field information on Form when we click on UPDATE button .

        actually with-out calling each individual field in server-side script [ gr.setValue(‘incident_state’, 6); ]…how to call all form fields and save whole form fields info….?

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

  2. 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.

  3. 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 *