- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-19-2017 02:48 PM
Someone helped me with this for a Table I have which in the Record Producer I have tons of variables but they only want to see the ones are that complete. I can get it to pull the values if i tell it the sys id to look for but I can't get it to pull the sys id of the record it just created. Any ideas? See the screenshot below the sys id is there and it's unique. TIA It's for a Record Producer that is put into a table with only like 4 fields and one of them is a comments section it wants the variable values to go into if they are completed. If they aren't completed they don't want to see them.
var gr = new GlideRecord('question_answer');
gr.addQuery('table_sys_id', current.sys.id); //sys_id of record in question
gr.query();
while (gr.next()) {
if (gr.value && gr.question.type == 6) { //exclude questions with empty values
current.u_comments +=(gr.question.getDisplayValue() + ": " + gr.value.getDisplayValue() + "\n"); //display question and answer
}
}
current.u_aom_analyst = gs.getUserID();
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2017 02:12 PM
Hi Wendy,
Can you please try the following and let me know how you get along: -
var sysID = current.getUniqueValue(); //find sys_id of current record
var gr = new GlideRecord('question_answer');
gr.addQuery('table_sys_id', sysID); //sys_id of record in question
gr.addNotNullQuery('value'); //exclude any variables with null values
gr.query();
var myComments = '';
while (gr.next()) {
if (gr.question.type == 6) { //restrict question type
myComments +=(gr.question.getDisplayValue() + ": " + gr.value.getDisplayValue() + "\n"); //build comments
}
}
//set fields on record producer
current.u_comments = myComments;
current.u_aom_analyst = gs.getUserID();
I could only test this in a background script with a fixed sys_id so you'll have to let me know if it works for you.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2017 04:43 AM
If I understood correctly, you need to fetch corresponding record's Table sys_id. If true, try this,
var tableName = current.getTableName();
var gr = new GlideRecord('question_answer');
gr.addQuery('table_sys_id', getTableSysID(tableName)); //sys_id of record in question
gr.query();
while (gr.next()) {
if (gr.value && gr.question.type == 6) { //exclude questions with empty values
current.u_comments +=(gr.question.getDisplayValue() + ": " + gr.value.getDisplayValue() + "\n"); //display question and answer
}
}
function getTableSysID(tableName){
var sdo = new GlideRecord('sys_db_object');
sdo.addQuery('name',tableName);
sdo.query();
if(sdo.next())
return sdo.sys_id;
else
return null;
}
Regards,
Nitesh Asthana
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2017 04:56 AM
Right so I have a Record Producer with a lot of variables. As shown below and when they complete it then it creates a record in the their table u_aom_bandwidth. And in their comments section they want to see information like this which is what I pulled when I looked for a specific ID. But now I can't get the values to pull across from that table. I can see that the values are there and the table sys id is unique. I tried what you put and that didn't work either
Select your Assignment Group:: AOM
Week Of : 2017-12-19
Please estimate your number of intakes this week:: 5
BI: 2
BI-Pub: 2

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2017 05:07 AM
comment field you are referring to is journal field, right?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2017 05:10 AM
No it's just a field I made like a Multiline text. Does it need to be a journaled field?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎12-20-2017 05:12 AM
I even tried creating another table with just a couple fields and couldn't get that to pull into it.