Service Portal Widget difference between: input, data and options (INPUT)

Elton2
Tera Contributor

Hi, good afternoon! 

I'm studying about widget and communication between: Server, Client and HTML.

 

in the documentation, says:

 "input variable is a data object sent from the client script, this variable is undefined when first initialized"

 

in short, "input" would be the user's access to information from the Server or Database? 

 

According to the attached image, the user initiates the interaction with the server through ng-click, then an "action" is created so that in the sequence the "input" occurs, then the information is transferred from the Server to the Client and finally to the HTML? Is this correct?

 

Thank you very much.

1 ACCEPTED SOLUTION

Cuong Phan
Kilo Sage

Hi Elton2,

Regarding "Input", lets say input is the object for user to interact with UI and transfer user's input to server side.

This is one of the use cases that we can implement. There are many more approaches we can do.

HTLM

<button ng-click="c.doSth()">Click the button</button>

Client

c.doSth = function() {
c.data.action = 'do_sth'; // This will transfer to input in server side
c.data.param1 = 'param1';  // This will transfer to input in server side
c.data.server.update(); // Trigger server side update
}


Server Side

if (input && input.action == 'do_sth') {

var param1 = c.input.param1;
// Update server side
var rec = new GlideRecord()
xxxx
xxxx

}

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.

 

Cuong Phan

Senior Consultant.

 

Regards,
Cuong Phan
ServiceNow Technical Lead

View solution in original post

2 REPLIES 2

Cuong Phan
Kilo Sage

Hi Elton2,

Regarding "Input", lets say input is the object for user to interact with UI and transfer user's input to server side.

This is one of the use cases that we can implement. There are many more approaches we can do.

HTLM

<button ng-click="c.doSth()">Click the button</button>

Client

c.doSth = function() {
c.data.action = 'do_sth'; // This will transfer to input in server side
c.data.param1 = 'param1';  // This will transfer to input in server side
c.data.server.update(); // Trigger server side update
}


Server Side

if (input && input.action == 'do_sth') {

var param1 = c.input.param1;
// Update server side
var rec = new GlideRecord()
xxxx
xxxx

}

Mark Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.

 

Cuong Phan

Senior Consultant.

 

Regards,
Cuong Phan
ServiceNow Technical Lead

Hi @Cuong Phan , how are you?

I appreciated your explanation, thank you for your attention support.

Thanks again! 😃