- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-03-2018 10:43 AM
Has anyone been able to link a request tasks to a change request similar as showing in this steps. Link changes to a project task I am able to see it creates a change from the task but I cant get the task to show up linked on the change request?
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-05-2018 09:58 AM
Thats great.. You found it. But it is referencing the Catalog Task instead of Change Request or Task table, while you in the script you are trying to store the change request. Something is wrong with the way it is implemented.
You also need to correct this line in the script.
link.eislinked_task = changeRequest.insert();
It should be
link.u_eis_linked_task = changeRequest.insert();
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2018 06:31 AM

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2018 10:52 AM
Can you post the code, how you are creating the Change Request. You should add a reference to the task or RITM on Change while creating the Change.
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2018 01:09 PM
I have the following code on the request task:
On table: sc_task
UI Action: Create Change and link from EIS Request
***************************
createChange();
function createChange() {
current.link = true;
current.rollup = true;
current.update();
action.setReturnURL(current);
var link = new GlideRecord("u_eis_task_link");
link.initialize();
link.parent = current.sys_id;
var changeRequest = new GlideRecord("change_request");
changeRequest.short_description = current.short_description;
link.eislinked_task = changeRequest.insert();
new EISTaskLinkUtils().copyChangeInfoToLink(link, changeRequest);
link.insert();
gs.addInfoMessage(gs.getMessage("Change Request {0} created", changeRequest.number));
action.setRedirectURL(changeRequest);
}
***********************************
The code above is to produce the link below on the task
The following scrip include:
EISTaskLinkUtils
***********************************
var EISTaskLinkUtils = Class.create();
EISTaskLinkUtils.prototype = {
initialize: function() {
},
/**
* Copies all the required data from the Change record to u_eis_task_link record
* 1. If the time is not in the schedule then the first time in the schedule after time
* 2. If the time is in the schedule then the first time in the schedule for the next day
*
* Usage
* var EnhancementTaskManagerUtil = new EnhancementTaskManagerUtil();
* var calculatedStartDate = EnhancementTaskManagerUtil.copyChangeInfoToLink(link, change);
*
* @method copyChangeInfoToLink
* @param {object} link : destination record from the table "u_eis_task_link" to be filled by this function
* @param {string} change : source record from the table "change" to be filled by this function
**/
copyChangeInfoToLink: function(link, change) {
link.short_description = change.short_description;
link.description = change.description;
link.state = change.state;
link.active = change.active;
link.time_constraint = "start_on";
if (!change.start_date.nil() && !change.end_date.nil()) {
link.start_date = change.start_date;
link.end_date = change.end_date;
} else {
var now_time = GlideSystemDateUtil.nowDateTime();
link.start_date = now_time;
link.time_constraint = "asap";
link.duration = "01 00:00:00";
}
link.work_start = change.work_start;
link.work_end = change.work_end;
link.approval = change.approval;
},
type: 'EISTaskLinkUtils'
};
**********************************************
UI page:Link an existing Change Request to the Task
********************************************
HTML Part:
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<form action="ui_page_process.do">
<input type="hidden" name="name" value="link_existing_change_to_task"/>
<input type="hidden" id="cancelled" name="cancelled" value="false"/>
<g:evaluate>
var parent_task = '${sysparm_sysID}';
var table_name = "change_request";
</g:evaluate>
<br/>
<span> Use the lookup icon to display records from the change request table</span>
<table>
<tr>
<td nowrap="true"> ${gs.getMessage('Change Request')}: </td>
<td colspan="4">
<g:ui_reference name="document_key" id="document_key" table="${table_name}"/>
</td>
</tr>
<tr>
</tr>
<tr id="dialogbuttons">
<td colspan="2" align="right">
<g2:dialog_button onclick="return onSubmit();" name="ok_button" id="ok_button">${gs.getMessage('OK')}</g2:dialog_button>
<g2:dialog_button onclick="return onCancel();" name="cancel_button" id="cancel_button">${gs.getMessage('Cancel')}</g2:dialog_button>
</td>
</tr>
</table>
<input type="hidden" name="parent_task" id="parent_task" value="${sysparm_sysID}"/>
</form>
</j:jelly>
Client Script Part:
********************************************
function setupReference() {
var tn = gel('table_name').value;
gel('document_keyTABLE').value = tn;
}
function setName() {
var task = gel('sys_original.document_key');
if (task)
$("document_name").value = task.value;
}
function onCancel() {
var c = gel('cancelled');
c.value = "true";
GlideDialogWindow.get().destroy();
return false;
}
function onSubmit() {
var task = gel('document_key').value;
if (task == "") {
alert(getMessage("Enter a valid change request to link"));
return false;
}
return true;
}
********************************************
********************************************
procession script part:
if (cancelled == "false") {
var parent = new GlideRecord("sc_task");
parent.get(parent_task);
if (parent.link != true) {
parent.link = true;
parent.update();
}
var change = new GlideRecord("change_request");
change.get(document_key);
var link = new GlideRecord("u_eis_task_link");
link.addQuery("parent", parent_task);
link.addQuery("eislinked_task", document_key);
link.query();
if (!link.hasNext()) {
link = new GlideRecord("u_eis_task_link");
link.initialize();
link.eislinked_task = document_key;
link.parent = parent_task;
var sys_id = link.insert();
link.get(sys_id);
new EISTaskLinkUtils().copyChangeInfoToLink(link, change);
link.update();
} else
gs.addErrorMessage(gs.getMessage("A link to the selected Change already exists"));
redirectTo();
}
function redirectTo() {
var urlOnStack = parent.sys_class_name + ".do?sys_id="
+ parent_task;
response.sendRedirect(urlOnStack);
}
********************************************
I might be doing this wrong but that's the code I'm using for this. Any help is much appreciated.
Thanks,
Osvaldo

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2018 01:18 PM
So you have it all in your script.
var link = new GlideRecord("u_eis_task_link");
link.initialize();
link.parent = current.sys_id;
var changeRequest = new GlideRecord("change_request");
changeRequest.short_description = current.short_description;
link.eislinked_task = changeRequest.insert();
new EISTaskLinkUtils().copyChangeInfoToLink(link, changeRequest);
link.insert();
In your change request form layout, expand the reference field eislinked_task. The eislinked_task will have a parent field. Move it to the right bucket and you will be able to see the task number.
Please mark this response as correct or helpful if it assisted you with your question.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-04-2018 02:25 PM