- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-26-2015 02:32 PM
I have create a record producer for change_request.
In this I am also creating change task for this change request.
So here I want to display all the variables in the record producer in change task description field like " <variable name1 >: <variable Value1>, <variable name2>: <variable Value3>}"
I tried some script by querying from "question_answer" table to get the variable details but It is not giving the variables.
Is there any way to loop all the variables.
Thanks In advance..
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2015 04:50 PM
try this:
var gr = new GlideRecord('question_answer');
gr.addQuery('table_sys_id', '1116a6870f0a020062b6e64be1050ec6'); //sys_id of record in question
gr.query();
while (gr.next()) {
if (gr.value) { //exclude questions with empty values
gs.print(gr.question.getDisplayValue() + ": " + gr.value); //display question and answer
}
}
should return something like:
*** Script: Please describe your issue below: user entered description
*** Script: Open on behalf of this user: 7839639120196100636f41ee6e8383d6
*** Script: Short description (Subject Line): user entered short description
will take a bit more work if you have referenced values.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2015 11:55 AM
Thats because you do not have any field called sysapproval in change request table.
Write a On before Insert BR on change task table with the below script(of course with proper conditions)
var varArray='';
var variables = new GlideRecord('question_answer');
variables.addQuery('table_sys_id', current.change_request);
variables.query();
while(variables.next())
{
varArray.push(variables.question.getDisplayValue()+" "+variables.value);
}
current.description=varArray.join();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-27-2015 04:50 PM
try this:
var gr = new GlideRecord('question_answer');
gr.addQuery('table_sys_id', '1116a6870f0a020062b6e64be1050ec6'); //sys_id of record in question
gr.query();
while (gr.next()) {
if (gr.value) { //exclude questions with empty values
gs.print(gr.question.getDisplayValue() + ": " + gr.value); //display question and answer
}
}
should return something like:
*** Script: Please describe your issue below: user entered description
*** Script: Open on behalf of this user: 7839639120196100636f41ee6e8383d6
*** Script: Short description (Subject Line): user entered short description
will take a bit more work if you have referenced values.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-15-2016 06:54 AM
Hi Erik,
Your code works like a charm, however do we know how I can get the current record's table_sys_id? is that possible?
Thanks,
Srini
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎09-19-2016 10:37 AM
the gr object will contain the table_sys_id at gr.table_sys_id. call gr.table_sys_id in the while loop as you see fit.
i'll use this as an opportunity to plug xplore. terrific tool to view the contents of an object. scripts - background? yeah, i remember when i had to use that. xplore ftw!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-31-2016 11:05 AM
Do you know if there is an equivalent table for sc_req_item? As question_answer is to record producer _______________ is to sc_req_item