- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2024 11:37 PM
Hi,
I have a requirement where if a user enters release number, the output should be a story's functional task number and its assigned to number. I have to do it through array.
In the for loop, i'm unable to get the scrum task number and the assigned to value.
var release_Num = 'RLSE0010002';
var release_Shortdes = 'Test';
var val = [];
var rel = new GlideRecord('rm_release_scrum');
rel.addQuery('number', release_Num);
rel.addQuery('short_description', release_Shortdes);
rel.query();
if (rel.next()) {
var id = rel.getUniqueValue();
var str = new GlideRecord('rm_story');
str.addQuery('release', id);
str.query();
while (str.next()) {
gs.print("StoryNumber" + " " + "-" + " " + str.number);
var stask = new GlideRecord('rm_scrum_task');
stask.addQuery('story', str.sys_id);
stask.addEncodedQuery('type=4^numberNOT LIKEITG^short_descriptionLIKEFunctional Testing');
stask.query();
while (stask.next()) {
val.push(stask.sys_id + '');
}
var value = val.toString();
var stri = value.split(',');
for (var i = 0; i < stri.length; i++) {
gs.print(stask.number[i]+' '+stask.assigned_to[i]);
}
}
}
Kindly help to get the values. Thanks for the response in advance.
Best Regards,
Manjushree
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2024 11:42 PM
Hi @Manju Shree
It appears you are encountering an issue when attempting to access and print the scrum task number and assigned to value after collecting all relevant sys_ids in an array. The core problem in your code snippet lies in the misuse of the GlideRecord variable stask inside your for loop, leading to incorrect attempts to index its properties like arrays, which they are not.
Let’s address and adjust the relevant sections of your code to achieve the desired output:
var release_Num = 'RLSE0010002';
var release_Shortdes = 'Test';
var rel = new GlideRecord('rm_release_scrum');
rel.addQuery('number', release_Num);
rel.addQuery('short_description', release_Shortdes);
rel.query();
if (rel.next()) {
var id = rel.getUniqueValue();
// Initialize stories GlideRecord
var str = new GlideRecord('rm_story');
str.addQuery('release', id);
str.query();
while (str.next()) {
gs.print("Story Number: " + str.number);
// Initialize scrum tasks GlideRecord
var stask = new GlideRecord('rm_scrum_task');
stask.addQuery('story', str.sys_id);
stask.addEncodedQuery('type=4^numberNOT LIKEITG^short_descriptionLIKEFunctional Testing');
stask.query();
while (stask.next()) {
// Instead of storing sys_id, let’s directly store the relevant info
var assignedToString = stask.assigned_to.nil() ? "Unassigned" : stask.assigned_to.getDisplayValue(); // This checks if assigned_to is empty and handles accordingly
gs.print("Scrum Task Number: " + stask.number + " Assigned To: " + assignedToString);
}
}
}
Note: Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning
Thanks & Regards
Deepak Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2024 11:42 PM
Hi @Manju Shree
It appears you are encountering an issue when attempting to access and print the scrum task number and assigned to value after collecting all relevant sys_ids in an array. The core problem in your code snippet lies in the misuse of the GlideRecord variable stask inside your for loop, leading to incorrect attempts to index its properties like arrays, which they are not.
Let’s address and adjust the relevant sections of your code to achieve the desired output:
var release_Num = 'RLSE0010002';
var release_Shortdes = 'Test';
var rel = new GlideRecord('rm_release_scrum');
rel.addQuery('number', release_Num);
rel.addQuery('short_description', release_Shortdes);
rel.query();
if (rel.next()) {
var id = rel.getUniqueValue();
// Initialize stories GlideRecord
var str = new GlideRecord('rm_story');
str.addQuery('release', id);
str.query();
while (str.next()) {
gs.print("Story Number: " + str.number);
// Initialize scrum tasks GlideRecord
var stask = new GlideRecord('rm_scrum_task');
stask.addQuery('story', str.sys_id);
stask.addEncodedQuery('type=4^numberNOT LIKEITG^short_descriptionLIKEFunctional Testing');
stask.query();
while (stask.next()) {
// Instead of storing sys_id, let’s directly store the relevant info
var assignedToString = stask.assigned_to.nil() ? "Unassigned" : stask.assigned_to.getDisplayValue(); // This checks if assigned_to is empty and handles accordingly
gs.print("Scrum Task Number: " + stask.number + " Assigned To: " + assignedToString);
}
}
}
Note: Please Mark this Helpful and Accepted Solution. If this Helps you to understand. This will help both the community and me..
- Keep Learning
Thanks & Regards
Deepak Sharma
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2024 11:49 PM
Thanks for your quick response. It worked.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-25-2024 11:48 PM
Hi @Manju Shree
Updated Code
var release_Num = 'RLSE0010002';
var release_Shortdes = 'Test';
var val = [];
var rel = new GlideRecord('rm_release_scrum');
rel.addQuery('number', release_Num);
rel.addQuery('short_description', release_Shortdes);
rel.query();
if (rel.next()) {
var id = rel.getUniqueValue();
var str = new GlideRecord('rm_story');
str.addQuery('release', id);
str.query();
while (str.next()) {
gs.print("StoryNumber" + " " + "-" + " " + str.number);
var stask = new GlideRecord('rm_scrum_task');
stask.addQuery('story', str.sys_id);
stask.addEncodedQuery('type=4^numberNOT LIKEITG^short_descriptionLIKEFunctional Testing');
stask.query();
while (stask.next()) {
gs.print(stask.number + ' ' + stask.assigned_to);
}
}
}