Error using $scope.page.g_form on the widget using Service Portal

Hari1
Mega Sage

Hi,

I have created a widget button on the portal called calculate which is a button. When i scan my update set i see the below warning message which is not allowing me to complete my update set inorder to export my update set.

"Widgets should use the "controller as" syntax in their client controller scripts. The first line of the client controller function should be "var c = this;" and c should be extended when creating new methods/properties, rather than doing so on $scope."

Below is the code on the Widget

Body HTML template

<div>
  <button  type="button" class="btn btn-info btn-block" ng-click="c.calculateValue()">Calculate</button>
</div>

Widget - client controller

api.controller = function($scope) {
    /* widget controller */
    var c = this;

    c.calculateValue = function() {
	
        var g_form = $scope.page.g_form;
		
        //alert("Inside the Widget function");
        
        var existingSoftwareCnt = parseInt(g_form.getValue('number_of_license')); //A1
        var licenceCost = parseInt(g_form.getValue('licensing_cost')); //B1
        var howManySupport = parseInt(g_form.getValue('number_of_fulfiller')); //x1
        var numberOfUsers = parseInt(g_form.getValue('si_support')); //y1

        var gsepEstmCost = (howManySupport * 45 * 12) + 50000;
		
        var addDolarSignGsep = "$" + gsepEstmCost;

        g_form.setValue('gsep_overhead_cost', addDolarSignGsep);

        // ****** Application Estimated Cost *****

        var totalServer = parseInt(g_form.getValue('total_servers_vm_prod_dev_test'));

        var appEstmCost = licenceCost + (totalServer * 12 * 360);
		
        var addDolarSignAppEst = "$" + appEstmCost;

        g_form.setValue('application_annual_cost', addDolarSignAppEst);

        // ****** Forcasted Annual Savings *****

        var forCastAnnualSav = appEstmCost - gsepEstmCost;

        var addDolarSignForCst = "$" + forCastAnnualSav;

        g_form.setValue('annual_savings', addDolarSignForCst);

    };
};
2 REPLIES 2

Kieran Anson
Kilo Patron

This sounds like a custom instance scan check as I can not find one matching this criteria in my environment. Can you post some details on what the instance check is doing (assuming its a script check?)

PaulaaO
Mega Sage

Did you find the solution for this in the end? The same appears in my scan and it's actually for an OOTB widget which I duplicated and only changed c to c1.