Based on parent CI value i need to reverse button item variable choice value

mani55
Tera Contributor

we have one button item to change parent CI field value using button item form so based on subnet_id i need to change the action choice in onload time i tried below widget but not working so please help me with mistake

 

Body HTML templat:

 

<div ng-init="onLoad()">
</div>

 

server script:

 

(function() {

    if (input.action == 'subnet') {

        var premium_service = new GlideRecord('u_alm_service');
         premium_service.get(input.premium_service);

        data.subnet_id = premium_service.ci.ref_u_cmdb_ci_sc_computer.u_domain.getDisplayValue();
		gs.log('the domain value'+ data.subnet_id);
      
    }

})();

client script:

 

function($scope) {
    var c = this;

    $scope.getSubnet = function() {
        c.server.get({
            action: 'subnet',
            premium_service: $scope.page.g_form.getValue('premium_service')
        }).then(function(response) {

            $scope.subnet_id = response.data.subnet_id;

			if($scope.subnet_id=='1'){
			
            $scope.page.g_form.setValue('action','0');
			}else if($scope.subnet_id=='0'){
             $scope.page.g_form.setValue('action','1');
		
			}
        })
    };


}

 

please check and let me know my mistake

0 REPLIES 0