Failed Trying to Execute on Connection

benm3
Mega Guru

Hi there,

I have recently committed an update set into another instance and have received these error while committing. The update set contained portal related modifications. I am not sure what it means and how to resolve it.

Any help and comments would be great!

 

FAILED TRYING TO EXECUTE ON CONNECTION glide.7 (connpid=18718): INSERT INTO sp_widget (`template`,`css`,`internal`,`link`,`description`,`sys_id`,`docs`,`public`,`client_script`,`id`,`field_list`,`demo_data`,`option_schema`,`script`,`has_preview`,`servicenow`,`data_table`,`name`,`category`,`controller_as`) VALUES('<div class=\"panel panel-{{c.options.color}} b\" ng-if=\"c.always_show ||c.data.list.length\">
  <div class=\"panel-heading\" >
    <h4 class=\"panel-title\">{{c.options.title}}</h4>
    <i class=\"fa fa-filter\" aria-hidden=\"true\" tabindex=\"0\" ng-click=\"c.showFilter = !myreq.showFilter;\" title=\"Show filters for {{c.options.title}}\"></i>
    <div ng-show=\"c.showFilter\">
      <input ng-model=\"c.filterText\" sn-focus=\"c.showFilter\" style=\"color: grey; width: 100%; margin-top: .5em;\" placeholder=\"{{data.filterMsg}}\">
    </div>
  </div>
  <div class=\"list-group\" style=\"max-height: none; overflow-y: auto;\">
    <div class=\"list-group-item\" ng-repeat=\"item in c.data.list | filter:c.filterText\" >
      <a href=\"{{item.url}}\"> 
        <div ng-class=\"{''l-h-40'': !item.secondary_fields.length}\">{{item.display_field}}</div>
        <small class=\"text-muted\" ng-repeat=\"f in item.secondary_fields\">
          <span ng-if=\"!$first\"> • </span>
          <span ng-switch=\"f.type\" title=\"{{::f.label}}\">
            <span ng-switch-when=\"glide_date\"><sn-time-ago timestamp=\"::f.value\" /></span>
            <span ng-switch-when=\"glide_date_time\"><sn-time-ago timestamp=\"::f.value\" /></span>
            <span ng-switch-default=\"\">{{f.display_value}}</span>
          </span>
        </small>
      </a>
    </div>
  </div>
  <div class=\"panel-footer\" ng-if=\"c.options.maximum_entries && c.data.count > c.options.maximum_entries\">
    <h4 class=\"panel-title\">${First {{c.options.maximum_entries}} of {{c.data.count}} shown}</h4>
  </div>
</div>','.panel-heading {
  position: relative;
  > .fa-filter { 
    position: absolute;
    top: 1rem; 
    right: 1rem; 
  }
}

.list-group-item > a {
	display: inline-block;
}',0,'function link(scope, element, attrs, controller) {  }',NULL,'097f6eeadb17fb00f8b17b598c9619cd',NULL,0,'function ($location, $rootScope) {
	var c = this;
	this.filterText = \"\";
	this.showFilter = false;

	this.onClick = function($event, item, url, action) {
		$event.stopPropagation();
		$event.preventDefault();
		if (url)
			$location.search(url);
		else {
			var evt = {};
			evt.url = url;
			evt.table = c.data.table;
			evt.sys_id = item.sys_id;
			evt.record = item;
			evt.rectangle_id = c.data.sys_id;
			evt.action = action;
			// put out the selection with simple list \"sl_\" prefix
			$location.search(''sl_sys_id'', evt.sys_id);
			$location.search(''sl_table'', evt.table);
			$location.search(''spa'', 1); // spa means \"I''ve got this\"
			$rootScope.$broadcast(''$sp.list.click'', evt);
		}
	};
}','watched-request-tickets','title,color',NULL,'[{\"hint\":\"Number of records to show\",\"name\":\"maximum_entries\",\"section\":\"Presentation\",\"label\":\"Maximum entries\",\"type\":\"integer\"}]','(function() {
	if (!options.maximum_entries)
		options.maximum_entries = 20;
	var gr = new GlideRecordSecure(''sc_req_item''); // does ACL checking for us // Change as well, was sc_req_item
	gr.addActiveQuery();
	//gr.addQuery(''active'', false);
	
	options.title = options.title || gr.getPlural();
	data.display_field = ''sys_created_on'';
	data.secondary_fields = [''number'',''sys_updated_on''];
	data.filterMsg = gs.getMessage(\"Filter...\");

	gr.addEncodedQuery(''watch_listDYNAMIC90d1921e5f510100a9ad2572f2b477fe'');// Change this as well. 
	gr.orderByDesc(''sys_created_on'');
	gr.query();
	data.count = gr.getRowCount();
	data.list = [];
	var recordIdx = 0;
	while (gr.next()) {
		if (recordIdx == options.maximum_entries)
			break;

		var record = {};
		record.sys_id = gr.getValue(''sys_id'');
		var ritm = new GlideRecord(\"sc_req_item\"); 
		ritm.addQuery(\"sys_id\", gr.getUniqueValue());
		ritm.query();
		if (ritm.getRowCount() == 0)
			continue;

		if (ritm.getRowCount() > 1)
			record.display_field = gs.getMessage(\"{0} watched requests.\", ritm.getRowCount());
		else {
			ritm.next();
			record.display_field = ritm.cat_item.getDisplayValue() || ritm.getDisplayValue(\"short_description\");
		}

		record.secondary_fields = [];
		data.secondary_fields.forEach(function(f) {
			record.secondary_fields.push(getField(gr, f));
		});

		record.url = \"/detechss?id=ticket&table=sc_req_item&sys_id=\"+record.sys_id+\"&view=sp\"; // Change that as well. 
		data.list.push(record);
		recordIdx++;
	}

	function getField(gr, name) {
		var f = {};
		f.display_value = gr.getDisplayValue(name);
		f.value = gr.getValue(name);
		var ge = gr.getElement(name);
		f.type = ge.getED().getInternalType()
		f.label = ge.getLabel();
		return f;
	}

})()
',0,0,'sp_instance','Watched Request Tickets','custom','c'),INSERT INTO sys_metadata (`sys_replace_on_upgrade`,`sys_updated_on`,`sys_class_name`,`sys_id`,`sys_updated_by`,`sys_created_on`,`sys_name`,`sys_scope`,`sys_created_by`,`sys_mod_count`,`sys_package`,`sys_update_name`,`sys_customer_update`,`sys_policy`) VALUES(0,'2019-08-19 13:47:47','sp_widget','097f6eeadb17fb00f8b17b598c9619cd','benadmin','2019-08-19 11:22:45','Watched Request Tickets','global','benadmin',4,'global','sp_widget_097f6eeadb17fb00f8b17b598c9619cd',0,NULL)
java.sql.BatchUpdateException: Duplicate entry 'watched-request-tickets' for key 'id'
1 ACCEPTED SOLUTION

Thanks David, gave me a good idea on how to resolve this issue. 

In this case, I just created a patch update set and re-committed the update set to the desired instance!

View solution in original post

2 REPLIES 2

DScroggins
Kilo Sage
Hello, That error is telling you there is already a widget with the id 'watched-request-tickets'. (Look at the very last line of the error message) As widget id is a unique field you can't have two with the same. In order to commit the new update set you can find the existing widget and change the id to something different. Then you will be able to commit the new one. Hope this helps. --David

Thanks David, gave me a good idea on how to resolve this issue. 

In this case, I just created a patch update set and re-committed the update set to the desired instance!