Add to Update Set is missing from records on PDI

Robert Campbell
Tera Guru

I expect to see the option to add to update set but I don't see it.

 

RobertCampbell_0-1695337855902.png

RobertCampbell_1-1695337930259.png

I don't see it in the actions either.

RobertCampbell_2-1695338048815.png

 

 

1 ACCEPTED SOLUTION

Robert Campbell
Tera Guru

RobertCampbell_0-1695388568320.png

 

Ah, it is a custom UI Action.

 

For the form link:

RobertCampbell_1-1695389134787.png

 

addToUpdateSet();

function addToUpdateSet(){
	//Get current URL for return
	var url = GlideSession.get().getStack().bottom();
	
	//Save current record
	current.update();
	
	//Initialize updateManager
	var updateManager = new GlideUpdateManager2();
	
	//Add record to update set
	updateManager.saveRecord(current);
	
	//If the current record is an attachment, add the chunks
	//(Attachments and chunks for other record types are auto-added)
	if (current.getTableName() == 'sys_attachment')
		addAttachmentChunks(current);

	//If attachments are not detected, check the sys_attachment table anyway
	//(Known attachments are auto-added, missing unknown attachments)
	//(sys_user seems to be an exception)
	else if (!current.hasAttachments() && current.getTableName() != 'sys_user')
		addAttachments(current);
	
	//Display confirmation
	var currentSet = new GlideRecord('sys_update_set');
	currentSet.get(gs.getPreference('sys_update_set'));
	gs.flushMessages(); //Flush to avoid multiples when list updating
	gs.addInfoMessage('Record(s) added to update set ' + currentSet.name + '.');
	action.setRedirectURL(url);
}

//Add attachments to the update set
function addAttachments(record){
	var updateManager = new GlideUpdateManager2();
	var attach = new GlideRecord("sys_attachment");
	attach.addQuery("table_sys_id", record.sys_id.toString());
	attach.query();
	while (attach.next()) {
		//Process main sys_attachment record
		updateManager.saveRecord(attach);
		
		//Process sys_attachment_doc chunks
		addAttachmentChunks(attach);
	}
}

//Add attachment chunks to the update set
function addAttachmentChunks(attachment){
	var updateManager = new GlideUpdateManager2();
	var attach_doc = new GlideRecord("sys_attachment_doc");
	attach_doc.addQuery("sys_attachment", attachment.sys_id.toString());
	attach_doc.orderBy("position");
	attach_doc.query();
	while (attach_doc.next())
		updateManager.saveRecord(attach_doc);
}

I'd make this accessible only to the admin role or some special privileged role.

 

For List Choice:

RobertCampbell_2-1695389222137.png

 

 

addToUpdateSet();

function addToUpdateSet(){
	//Get current URL for return
	var url = GlideSession.get().getStack().bottom();
	
	//Save current record
	current.update();
	
	//Initialize updateManager
	var updateManager = new GlideUpdateManager2();
	
	//Add record to update set
	updateManager.saveRecord(current);
	
	//If the current record is an attachment, add the chunks
	//(Attachments and chunks for other record types are auto-added)
	if (current.getTableName() == 'sys_attachment')
		addAttachmentChunks(current);

	//If attachments are not detected, check the sys_attachment table anyway
	//(Known attachments are auto-added, missing unknown attachments)
	//(sys_user seems to be an exception)
	else if (!current.hasAttachments() && current.getTableName() != 'sys_user')
		addAttachments(current);
	
	//Display confirmation
	var currentSet = new GlideRecord('sys_update_set');
	currentSet.get(gs.getPreference('sys_update_set'));
	gs.flushMessages(); //Flush to avoid multiples when list updating
	gs.addInfoMessage('Record(s) added to update set ' + currentSet.name + '.');
	action.setRedirectURL(url);
}

//Add attachments to the update set
function addAttachments(record){
	var updateManager = new GlideUpdateManager2();
	var attach = new GlideRecord("sys_attachment");
	attach.addQuery("table_sys_id", record.sys_id.toString());
	attach.query();
	while (attach.next()) {
		//Process main sys_attachment record
		updateManager.saveRecord(attach);
		
		//Process sys_attachment_doc chunks
		addAttachmentChunks(attach);
	}
}

//Add attachment chunks to the update set
function addAttachmentChunks(attachment){
	var updateManager = new GlideUpdateManager2();
	var attach_doc = new GlideRecord("sys_attachment_doc");
	attach_doc.addQuery("sys_attachment", attachment.sys_id.toString());
	attach_doc.orderBy("position");
	attach_doc.query();
	while (attach_doc.next())
		updateManager.saveRecord(attach_doc);
}

View solution in original post

5 REPLIES 5

SanjivMeher
Kilo Patron
Kilo Patron

Did you add this utility to you instance?
https://developer.servicenow.com/connect.do#!/share/contents/9824957_add_to_update_set_utility?v=7.3... 


Please mark this response as correct or helpful if it assisted you with your question.

The plugin is installed by default.

RobertCampbell_0-1695387387148.png

 

Harish Bainsla
Tera Sage
Tera Sage

if you are talking about record so update set did not capture records

Harish Bainsla
Tera Sage
Tera Sage

The transnational data such as incident, change, problem, knowledge, CI's etc data records, scheduled jobs, schedules, users, group, email etc are not get captured in update set.