- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-20-2016 07:53 PM
Hello
I need to Auto populate the Test Plan[tm_test_plan] and Test Case [tm_test_case_instance] to the Report Defect[rm_defect] form which is in the Test case form. Attaching the screenshot for better understanding. Any idea in this?
Test Case Form:
---------------------------
Report Defect form:
----------------------------
Thanks,
Alad.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2016 02:11 PM
This is how i added the query and it worked for me.
this.dialog.addParm('sysparm_query', 'description='+this._blockedReason+'^u_steps_to_reproduce='+this._testSteps);
One more important step to do while testing is clear your browser cache. What ever changes you made won't show up till you clear cache.
Hope this helps.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-21-2016 06:49 AM
Found this is working with an ui script "tm_ReportDefect", Blocked reason field auto populates to the description field of report defect, but when i add the Test case and Test plan to autopopulate its not working. Any help in this
/* Takes care of launching new Defect form and inserting mapping record*/
var tm_ReportDefect = Class.create();
tm_ReportDefect.prototype = {
initialize: function (_gForm) {
this._defectTable = 'rm_defect';
this._defectViewName = 'Scrum';
this._gForm = _gForm;
this._numbers = this._gForm.getValue('short_description'); // my added code
this._blockedReason = this._gForm.getValue('blocked_reason');
this._sysId = this._gForm.getUniqueValue();
this._tableName = this._gForm.getTableName();
/* If the defect is being reported from Test form */
if (this._tableName == 'tm_test_instance') {
this._sysId = this._gForm.getValue('tm_test_case_instance');
}
this.dialogClass = typeof GlideModalForm != 'undefined' ? GlideModalForm : GlideDialogForm;
this.dialog = new this.dialogClass('Report Defect', this._defectTable); //Provide dialog title and table name
this.dialog.setSysID(-1); //Pass in sys_id to edit existing record, -1 to create new record
this.dialog.addParm('sysparm_view', this._defectViewName); //Specify a form view
this.dialog.addParm('sysparm_form_only', 'true'); //Add or remove related lists
this.dialog.addParm('sysparm_query', 'description='+this._blockedReason); // populate description field with blocked reason
this.dialog.setCompletionCallback(this.onComplete.bind(this)); // Add completion callback
},
showDialog: function () {
/* Save record before creating defect
if(this._gForm.modified) {
this.gFrom.save();
}*/
this.dialog.render();
},
onLoad: function (iframeDoc) {
// To get the iframe: document.defaultView in non-IE, document.parentWindow in IE
var dialogFrame = 'defaultView' in iframeDoc ? iframeDoc.defaultView : iframeDoc.parentWindow;
/* Pre-populate description with blocked reason. */
if (dialogFrame != undefined && this._blockedReason != undefined && dialogFrame.g_form != undefined) {
dialogFrame.g_form.setValue('description', this._blockedReason);
dialogFrame.g_form.setValue('short_description', this._numbers); //my added code
}
},
onComplete: function (info1, defectSysId, tableName, displayValue) {
this.defectId = defectSysId;
this.defectNumber = displayValue;
var ga = new GlideAjax("tm_AjaxProcessor");
ga.addParam('sysparm_name', 'mapDefectToTestCase');
ga.addParam('sysparm_sysId', this._sysId);
/* Target Test Plan Sys_id */
ga.addParam('sysparm_defect', this.defectId);
/* Type of record being added to Test Plan, here Test Suite */
ga.addParam('sysparm_tn', 'tm_test_case_instance');
ga.getXML(this.callback.bind(this));
},
callback: function (response) {
var resp = response.responseXML.getElementsByTagName("result");
if (resp[0] && resp[0].getAttribute("status") == "success") {
/* Refresh related list only if the defect is being reported from Test case Instance form */
if (this._tableName == 'tm_test_case_instance') {
GlideList2.get(g_form.getTableName() + '.REL:5da20971872121003706db5eb2e3ec0b').setFilterAndRefresh('');
}
/* Info Message with link to newly created defect. */
this._gForm.addInfoMessage("<p>Defect <a href='rm_defect.do?sys_id=" + this.defectId + "'>" + this.defectNumber + "</a> has been created.</p>");
} else {
this._createError = new GlideModal("tm_error_dialog");
this._createError.setTitle(getMessage("Error while adding Test Cases from selected Test Suite."));
this._createError.render();
}
},
type: 'tm_ReportDefect'
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎04-14-2016 10:04 AM
Hi all,
I managed to populate field values from tm_test_case_instance(Test Case) to report defect form (rm_defect), but the issue is the code only populate it for a single field, how to pass multiple parameter using this code
Note: Need to populate multiple fields in the Report Defect form.
// Apart of the code from tm_ReportDefect [UI Script].
==========================================
var tm_ReportDefect = Class.create();
tm_ReportDefect.prototype = {
initialize: function (_gForm) {
this._defectTable = 'rm_defect';
this._defectViewName = 'Scrum';
this._gForm = _gForm;
this._blockedReason = this._gForm.getValue('blocked_reason');
this._shortdesc = this._gForm.getValue('short_description');
this._assigto = this._gForm.getValue('assigned_to');
this._testplan = this._gForm.getValue('tm_test_plan');
this._sysId = this._gForm.getUniqueValue();
this._tableName = this._gForm.getTableName();
/* If the defect is being reported from Test form */
if (this._tableName == 'tm_test_instance') {
this._sysId = this._gForm.getValue('tm_test_case_instance');
}
this.dialogClass = typeof GlideModalForm != 'undefined' ? GlideModalForm : GlideDialogForm;
this.dialog = new this.dialogClass('Report Defect', this._defectTable); //Provide dialog title and table name
this.dialog.setSysID(-1); //Pass in sys_id to edit existing record, -1 to create new record
this.dialog.addParm('sysparm_view', this._defectViewName); //Specify a form view
this.dialog.addParm('sysparm_form_only', 'true'); //Add or remove related lists
this.dialog.addParm('sysparm_query', 'description='+this._blockedReason); // populate description field with blocked reason
this.dialog.addParm('sysparm_query', 'u_test_plan='+this._testplan);
this.dialog.addParm('&sysparm_query', 'short_description='+this._shortdesc);
//this.dialog.addParm('sysparm_query', 'assigned_to%3D'+this._assigto+'&u_test_plan%3D'+this._testplan); // this doesnt work to popullate multiple fields
this.dialog.setCompletionCallback(this.onComplete.bind(this)); // Add completion callback
},
showDialog: function () {
// Save record before creating defect
if(this._gForm.modified) {
this.gFrom.save();
}
this.dialog.render();
},
Thanks in Advance.
-Alad.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-01-2016 05:48 PM
Also, editing of the UI script can also be tricky in some places where browsers cache the JS and changes are not always seen after saved.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-06-2016 02:11 PM
This is how i added the query and it worked for me.
this.dialog.addParm('sysparm_query', 'description='+this._blockedReason+'^u_steps_to_reproduce='+this._testSteps);
One more important step to do while testing is clear your browser cache. What ever changes you made won't show up till you clear cache.
Hope this helps.