Service Portal Widget

SohaP
Tera Contributor

Hello everyone,
I am looking for some help.
I am trying to send the selected value from user from client side to server side. The value successfully getting sent to the server side but I am not sure what exactly should be the server side script to fetch this value.

 

 

 

 

 

 

 

 

 

5 REPLIES 5

James Chun
Kilo Patron

Hi @SohaP,

 

Can you elaborate on what you are trying to do?

Are you trying to invoke a function within a Script Include and pass back its output?

 

Cheers

SohaP
Tera Contributor

Hi @James Chun,
I am trying to store the value of selected option in a server side variable.

Try replacing the following clinet script:

 $scope.selectedOption = option;
        $scope.selectedAction = action;

        // Making an HTTP POST request to send the selected option to the server
        $http.post('/sys_script_include_name.do', { option: option })
            .then(function(response) {
					      $scope.saveStatus = response.data;
                alert('Selected option sent to server successfully:', response.data);
            })
            .catch(function(error) {
                alert('Error sending selected option to server:', error);
            });
    };

 

to

 

c.server.get({
    action: "passClientValue",
    selectedOption = option,
    selectedAction = action
}).then(function(response) {
    //do some processing from reponse if reqired

});

 

And your Server script will be:

if(input && input.action == 'passClientValue')
{
	var selectedOption = input.selectedOption;
	var selectedAction = input.selectedAction;
	//Write some script here
}

 

SohaP
Tera Contributor

I tried this script but unfortunately it is also not working.