Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Service Portal Widget Options

Ken83
Mega Guru

Hello Community,

        I have created a widget and edited the options schema to include 2 options.

        - table : a reference field to the sys_db_object table

        - btn_text : a string of text

        Can someone explain why I am not able to access or see these options in the client controller by using $scope.options or c.options ? I logged the $scope object and c.options, the latter showing as undefined.

find_real_file.png

The problem this is creating for me is that the widget is not displaying properly and not behaving properly.

find_real_file.png

That should be a button consisting of the text outlined in the options.

Any suggestions on what is going wrong here?

5 REPLIES 5

Chuck Tomasi
Tera Patron

Did you remember to declare $scope in your function?



Example:



find_real_file.png


Yep, I sure did. Here is a snippet of the client script..



function($uibModal, $scope, spUtil) {


console.log($scope);


$scope.addRecordModal = function(){


        $uibModal.open({


                  templateUrl: 'form.do',


                  scope: $scope,


                  size: 'lg'


        });


        spUtil.get("widget-form", {sys_id: "-1", table: 'incident'}).then(function(response){


                  $scope.formWidget = response;


        });


};


}


jesseadams
ServiceNow Employee
ServiceNow Employee

Did you set the options in the widget instance?


Are you able to access them in the server script using options.table and options.btn_text?


That was my next question as well.