The Zurich release has arrived! Interested in new features and functionalities? Click here for more

How to pass catalog values to widget client

Naga Surendra 1
Mega Expert

Hi All,

i want to read the value from catalog fields in widget client controller.

find_real_file.png

when i click the button, the function needs to get value   of website url in client controller.

Html :

<div>

      <input type="button" ng-click="c.clearForm()" class="btn btn-primary" ng-model="website_url" value="Check Website"/>

   

</div>

client controller:

function($scope){

var c= this;

$scope.c.clearForm = function(){

gs.log("website"+$scope.website_url);

c.server.update().then(function(respons){

})

}

}

which method i need to use get value of catalog variable in the client controller. please advice me.

Regards,

Surendra

1 ACCEPTED SOLUTION

adityaghosh
Tera Guru

i assume you are taking about catalog variables, if yes? then ..



e.g. if variable name is u_name then in controller..type in



$scope.page.g_form.getValue('u_name'); // this will fetch the value of variable u_name



||rly $scope.page.g_form.setValue('u_name','Aditya');



etc..




in brief use prefix $scope.page.


View solution in original post

4 REPLIES 4

Harish KM
Kilo Patron
Kilo Patron

Here is one example


Interact with service portal widget in catalog item


Regards
Harish

adityaghosh
Tera Guru

i assume you are taking about catalog variables, if yes? then ..



e.g. if variable name is u_name then in controller..type in



$scope.page.g_form.getValue('u_name'); // this will fetch the value of variable u_name



||rly $scope.page.g_form.setValue('u_name','Aditya');



etc..




in brief use prefix $scope.page.


Hi Ghosh,



Thanks for response.


I tried with the below its not reading from the field.



function($scope) {  


        var c = this;  


      c.clearForm = function(){


var abc =$scope.page.g_form.getvalue("website_url");


alert("from the button:"+abc);


c.server.update().then(function(response){


//c.data.weburl=$scope.page.g_form.getvalue("website_url");


})


}


     


}  


try this...




function($scope, spMacro, spUtil, $uibModal, $http,   $timeout) {


      alert( $scope.page.g_form.getValue("website_url");


}








e.g. i used




<input type="button" ng-mouseover="GetFromServer_1()" ng-click="addNew_1(TableInfos_1)" class="btn btn-primary addNew_1 pull-right" value="Add New"/>


     




CS--




function($scope, spMacro, spUtil, $uibModal, $http,   $timeout) {




$scope.addNew_1 = function(TableInfos_1){


//ServerScript


//$scope.GetFromServer_1();


//map variables


$scope.InitVars_1();




//checking mandatory and valid entries


if (!$scope.ReqNDup_1()) return;


var arrval= "";


//alert($scope.getValsCnt_1); index start from 0, ignoring the last split


var item = {};


:


:


:


:


:


:


}



you may look at below link, where in portal widget I have used time element in HTML and in CS, I am fetching its


value & storing into a catalog variable..



ServiceNow Share