Service Portal Form Widget - Create new UI Action

Bianca1
Giga Contributor

Is it possible to create a new UI Action for a cloned Form Widget that will not check for the canWrite() function? 

The OOB widget requires GlideRecordSecure, however we are trying to handle write access separately.

1 ACCEPTED SOLUTION

Basically, yes.

Here is what I have done:

Inside my cloned form widget, I modified the $scope.getPrimaryAction function to get the Purple UI Action I created, here is the code:

$scope.getPrimaryAction = function() {
		var primaryActions = $scope.data.f._ui_actions.filter(function(action) {
        if(action.action_name == "iap_app_save") {
            return action;
        }
    });
    return primaryActions;
	}

Below is the $scope.data object showing where I got the Purple UI Action (purple box). You can also see below that the Blue UI Action(blue box) is stored in the same _ui_actions array:
find_real_file.png

I thought this would work (the Blue save button appears on the form) however, it is not saving and  I am getting the error:

Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: [[{"msg":"getPrimaryAction()","newVal":[{"sys_id":"ee26259a204080940221e6e73fc108ac","is_link":false,"action_name":"iap_app_save","name":"Save ","is_button":true,"is_context":false}],"oldVal":["..."]}],[{"msg":"getPrimaryAction()","newVal":["..."],"oldVal":"..."}],[{"msg":"getPrimaryAction()","newVal":["..."],"oldVal":"..."}],[{"msg":"getPrimaryAction()","newVal":["..."],"oldVal":"..."}],[{"msg":"getPrimaryAction()","newVal":["..."],"oldVal":"..."}]]
http://errors.angularjs.org/1.5.11/$rootScope/infdig?p0=10&p1=%5B%5B%7B%22msg%22%3A%22getPrimaryAction()%22%2C%22newVal%22%3A%5B%7B%22sys_id%22%3A%22ee26259a204080940221e6e73fc108ac%22%2C%22is_link%22%3Afalse%2C%22action_name%22%3A%22iap_app_save%22%2C%22name%22%3A%22Save%20%22%2C%22is_button%22%3Atrue%2C%22is_context%22%3Afalse%7D%5D%2C%22oldVal%22%3A%5B%22...%22%5D%7D%5D%2C%5B%7B%22msg%22%3A%22getPrimaryAction()%22%2C%22newVal%22%3A%5B%22...%22%5D%2C%22oldVal%22%3A%22...%22%7D%5D%2C%5B%7B%22msg%22%3A%22getPrimaryAction()%22%2C%22newVal%22%3A%5B%22...%22%5D%2C%22oldVal%22%3A%22...%22%7D%5D%2C%5B%7B%22msg%22%3A%22getPrimaryAction()%22%2C%22newVal%22%3A%5B%22...%22%5D%2C%22oldVal%22%3A%22...%22%7D%5D%2C%5B%7B%22msg%22%3A%22getPrimaryAction()%22%2C%22newVal%22%3A%5B%22...%22%5D%2C%22oldVal%22%3A%22...%22%7D%5D%5D
    at js_includes_sp.jsx?v=11-11-2018_0542&lp=Mon_Jul_08_20_42_23_PDT_2019&c=34_400:6416
    at Scope.$digest (js_includes_sp.jsx?v=11-11-2018_0542&lp=Mon_Jul_08_20_42_23_PDT_2019&c=34_400:14750)
    at ChildScope.$apply (js_includes_sp.jsx?v=11-11-2018_0542&lp=Mon_Jul_08_20_42_23_PDT_2019&c=34_400:14816)
    at HTMLLIElement.<anonymous> (js_includes_sp.jsx?v=11-11-2018_0542&lp=Mon_Jul_08_20_42_23_PDT_2019&c=34_400:67080)
    at HTMLLIElement.dispatch (js_includes_sp.jsx?v=11-11-2018_0542&lp=Mon_Jul_08_20_42_23_PDT_2019&c=34_400:3003)
    at HTMLLIElement.elemData.handle (js_includes_sp.jsx?v=11-11-2018_0542&lp=Mon_Jul_08_20_42_23_PDT_2019&c=34_400:2877)

Link to AngularJS

Any idea of what I am doing wrong?

 

Thanks,

Bianca

View solution in original post

7 REPLIES 7

Basically, yes.

Here is what I have done:

Inside my cloned form widget, I modified the $scope.getPrimaryAction function to get the Purple UI Action I created, here is the code:

$scope.getPrimaryAction = function() {
		var primaryActions = $scope.data.f._ui_actions.filter(function(action) {
        if(action.action_name == "iap_app_save") {
            return action;
        }
    });
    return primaryActions;
	}

Below is the $scope.data object showing where I got the Purple UI Action (purple box). You can also see below that the Blue UI Action(blue box) is stored in the same _ui_actions array:
find_real_file.png

I thought this would work (the Blue save button appears on the form) however, it is not saving and  I am getting the error:

Uncaught Error: [$rootScope:infdig] 10 $digest() iterations reached. Aborting!
Watchers fired in the last 5 iterations: [[{"msg":"getPrimaryAction()","newVal":[{"sys_id":"ee26259a204080940221e6e73fc108ac","is_link":false,"action_name":"iap_app_save","name":"Save ","is_button":true,"is_context":false}],"oldVal":["..."]}],[{"msg":"getPrimaryAction()","newVal":["..."],"oldVal":"..."}],[{"msg":"getPrimaryAction()","newVal":["..."],"oldVal":"..."}],[{"msg":"getPrimaryAction()","newVal":["..."],"oldVal":"..."}],[{"msg":"getPrimaryAction()","newVal":["..."],"oldVal":"..."}]]
http://errors.angularjs.org/1.5.11/$rootScope/infdig?p0=10&p1=%5B%5B%7B%22msg%22%3A%22getPrimaryAction()%22%2C%22newVal%22%3A%5B%7B%22sys_id%22%3A%22ee26259a204080940221e6e73fc108ac%22%2C%22is_link%22%3Afalse%2C%22action_name%22%3A%22iap_app_save%22%2C%22name%22%3A%22Save%20%22%2C%22is_button%22%3Atrue%2C%22is_context%22%3Afalse%7D%5D%2C%22oldVal%22%3A%5B%22...%22%5D%7D%5D%2C%5B%7B%22msg%22%3A%22getPrimaryAction()%22%2C%22newVal%22%3A%5B%22...%22%5D%2C%22oldVal%22%3A%22...%22%7D%5D%2C%5B%7B%22msg%22%3A%22getPrimaryAction()%22%2C%22newVal%22%3A%5B%22...%22%5D%2C%22oldVal%22%3A%22...%22%7D%5D%2C%5B%7B%22msg%22%3A%22getPrimaryAction()%22%2C%22newVal%22%3A%5B%22...%22%5D%2C%22oldVal%22%3A%22...%22%7D%5D%2C%5B%7B%22msg%22%3A%22getPrimaryAction()%22%2C%22newVal%22%3A%5B%22...%22%5D%2C%22oldVal%22%3A%22...%22%7D%5D%5D
    at js_includes_sp.jsx?v=11-11-2018_0542&lp=Mon_Jul_08_20_42_23_PDT_2019&c=34_400:6416
    at Scope.$digest (js_includes_sp.jsx?v=11-11-2018_0542&lp=Mon_Jul_08_20_42_23_PDT_2019&c=34_400:14750)
    at ChildScope.$apply (js_includes_sp.jsx?v=11-11-2018_0542&lp=Mon_Jul_08_20_42_23_PDT_2019&c=34_400:14816)
    at HTMLLIElement.<anonymous> (js_includes_sp.jsx?v=11-11-2018_0542&lp=Mon_Jul_08_20_42_23_PDT_2019&c=34_400:67080)
    at HTMLLIElement.dispatch (js_includes_sp.jsx?v=11-11-2018_0542&lp=Mon_Jul_08_20_42_23_PDT_2019&c=34_400:3003)
    at HTMLLIElement.elemData.handle (js_includes_sp.jsx?v=11-11-2018_0542&lp=Mon_Jul_08_20_42_23_PDT_2019&c=34_400:2877)

Link to AngularJS

Any idea of what I am doing wrong?

 

Thanks,

Bianca

i believe the "primary" button is the one that has the lowest value in the Order field that the form is seeing, it should attach that one to the save button.  what is the value to the update button vs save for order field?

ServiceNow's primary UI action for a form has the following characteristics: 
 
  • A matching table name, parent table name, or global
  • An action name of "sysverb_insert" or "sysverb_update"
  • A form button set to true
  • The lowest order, defined in the order field of the sys_ui_action table