
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-24-2018 11:10 AM
We have a catalog task that ask the user some questions. There are about 20 on the task that the user must complete to be able to close the task. Many qestons are Yes/No answers. Some of the questions, if they answer Yes, we ask them to "Please specify". A text box is then displayed allowing them to elaborate.
What we have provided is a UI action on the task that lets them basically "print" the questions and answers in a nicely formatted page.
I have gotten the questions and answers to display using the following
<j:if test="${grRITM.variables.rqst_legacy_access_question_solution == 'yes'}">
<tr>
<td class="tg-labelSrvy">Outline the solution to provide access to the legacy data:</td>
<td class="tg-attrSrvy"></td>
<td class="tg-attrSrvy">${grRITM.variables.rqst_legacy_access_question_sol_yes.getDisplayValue()}</td>
</tr>
</j:if>
The above works very well with the exception that the Text of the question is basically hard coded. I know that there is a GlideForm command that permits getting the label of a field.
g_form.getLabelOf('comments');
I am very new to jelly and here is my issue. If I change the text of the question in the service catalog item and the user displays the UI Page, the "hard coded" text display and does not match what was in the catalog task.
Is there a way got get the "label" text of the variable in the jelly code?
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2018 03:39 PM
All working now:
Turned out to be an extra character in the evaluate that was preventing the script from executing some of the statements.
Code
<g:evaluate>
var instanceURI = gs.getProperty('glide.servlet.uri');
var logoURI = instanceURI + 'DriveIT_CNHi_FCA_logo_small.png';
var currentDate = gs.now();
var taskID = '${sysparm_id}';
var strQuery = 'sys_idIN ';
var grTask = new GlideRecord('sc_task'); // Get the current task
grTask.get(taskID);
var grRITM = new GlideRecord('sc_req_item'); // Get the parent of the task
grRITM.get(grTask.request_item);
var taskSubType = grTask.u_task_sub_type;
var sundwnQuestionaire = taskSubType == 'cto_sundwn_questions' ? true : false;
grRITM_rqst_date_of_last_usage = grRITM.variables.rqst_date_of_last_usage.getGlideObject().getQuestion().getLabel();
grRITM_rqst_business_ok = grRITM.variables.rqst_business_ok.getGlideObject().getQuestion().getLabel();
grRITM_rqst_legacy_access_question = grRITM.variables.rqst_legacy_access_question.getGlideObject().getQuestion().getLabel();
grRITM_rqst_legacy_access_question_solution = grRITM.variables.rqst_legacy_access_question_solution.getGlideObject().getQuestion().getLabel();
<!-- G E T Q U E S T I O N L A B E L S -->
grRITM_rqst_mf_question = grRITM.variables.rqst_mf_question.getGlideObject().getQuestion().getLabel();
grRITM_rqst_up_down_stream = grRITM.variables.rqst_up_down_stream.getGlideObject().getQuestion().getLabel();
grRITM_rqst_datacenter_hosted = grRITM.variables.rqst_datacenter_hosted.getGlideObject().getQuestion().getLabel();
<!-- Application Access Variables -->
grRITM_rqst_access_removal = grRITM.variables.rqst_access_removal.getGlideObject().getQuestion().getLabel();
</g:evaluate>
The above sets the variables and below is
<div class="server_list_header"><h3>Survey Questions</h3></div>
<table class="tg">
<thead>
<tr class="pm_table_header">
<th class="sd_hdr_35_doc">Question</th>
<th class="sd_hdr_10_doc">Response</th>
<th class="sd_hdr_55_doc">Comments</th>
</tr>
</thead>
<tbody class="pm_ci_table_body">
<tr>
<td class="tg-labelSrvy">${grRITM_rqst_date_of_last_usage}:</td>
<td class="tg-attrSrvy">${grRITM.variables.rqst_date_of_last_usage.getDisplayValue()}</td>
<td class="tg-attrSrvy"></td>
</tr>
<tr>
<td class="tg-labelSrvy">Has the Business agreed to sundown?</td>
<td class="tg-attrSrvy">${grRITM.variables.rqst_business_ok.getDisplayValue()}</td>
<td class="tg-attrSrvy"></td>
</tr>
<tr>
<td class="tg-labelSrvy">Is there any requirement (e.g. business, record retention, legal hold) for users to maintain access to the legacy data?</td>
<td class="tg-attrSrvy">${grRITM.variables.rqst_legacy_access_question.getDisplayValue()}</td>
<td class="tg-attrSrvy">${grRITM.variables.rqst_legacy_acces_list.getDisplayValue()}</td>
</tr>
<tr>
<td class="tg-labelSrvy">Does the application currently have a solution to access the legacy data?</td>
<td class="tg-attrSrvy">${grRITM.variables.rqst_legacy_access_question_solution.getDisplayValue()}</td>
<td class="tg-attrSrvy"></td>
</tr>
<j:if test="${grRITM.variables.rqst_legacy_access_question_solution == 'yes'}">
<tr>
<td class="tg-labelSrvy">Outline the solution to provide access to the legacy data:</td>
<td class="tg-attrSrvy"></td>
<td class="tg-attrSrvy">${grRITM.variables.rqst_legacy_access_question_sol_yes.getDisplayValue()}</td>
</tr>
</j:if>
<j:if test="${grRITM.variables.rqst_legacy_access_question_solution == 'no'}">
<tr>
<td class="tg-labelSrvy">Specify the legacy data that must be archived:</td>
<td class="tg-attrSrvy"></td>
<td class="tg-attrSrvy">${grRITM.variables.rqst_legacy_access_question_sol_no.getDisplayValue()}</td>
</tr>
</j:if>
<tr>
<td class="tg-section" colspan="3" >General Section</td>
</tr>
<tr>
<td class="tg-labelSrvy">${grRITM_rqst_mf_question}</td>
<td class="tg-attrSrvy" colspan="2">${grRITM.variables.rqst_mf_question.getDisplayValue()}</td>
</tr>
<tr>
<td class="tg-labelSrvy">${grRITM_rqst_up_down_stream}</td>
<td class="tg-attrSrvy" colspan="2">${grRITM.variables.rqst_up_down_stream.getDisplayValue()}</td>
</tr>
<tr>
<td class="tg-labelSrvy">${grRITM_rqst_datacenter_hosted}</td>
<td class="tg-attrSrvy" colspan="2">${grRITM.variables.rqst_datacenter_hosted.getDisplayValue()}</td>
</tr>
<tr>
<td class="tg-section" colspan="3" >APPLICATION Access</td>
</tr>
<j:choose>
<j:when test="${grRITM.variables.rqst_access_removal == 'yes'}">
<tr>
<td class="tg-labelSrvy">${grRITM_rqst_access_removal}</td>
<td class="tg-attrSrvy">${grRITM.variables.rqst_access_removal.getDisplayValue()}</td>
<td class="tg-attrSrvy">${grRITM.variables.rqst_access_removal_list.getDisplayValue()}</td>
</tr>
</j:when>
<j:otherwise>
<tr>
<td class="tg-labelSrvy">${grRITM_rqst_access_removal}</td>
<td class="tg-attrSrvy">${grRITM.variables.rqst_access_removal.getDisplayValue()}</td>
<td class="tg-attrSrvy"></td>
</tr>
</j:otherwise>
</j:choose>
....
</tbody>
</table>
Sample of what if looks like:

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-24-2018 11:49 AM
You might be able to use this code;
grRITM.variables.rqst_legacy_access_question_sol_yes.getGlideObject().getQuestion().getLabel();
Taken from here
If that doesnt work you may need to get the question, its label and the value from the mtom table instead. This is overkill but it gets all the bits.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-24-2018 12:18 PM
I was also hoping that I could use that. I tried the following:
<g:evaluate>
var instanceURI = gs.getProperty('glide.servlet.uri');
var currentDate = gs.now();
var taskID = '${sysparm_id}';
var strQuery = 'sys_idIN ';
var grTask = new GlideRecord('sc_task'); // Get the current task
grTask.get(taskID);
var grRITM = new GlideRecord('sc_req_item'); // Get the parent of the task
grRITM.get(grTask.request_item);
<!-- grRITM_MF_question = grRITM.variables.rqst_mf_question.getLabel(); -->
<!-- grRITM_MF_question = grRITM.variables.rqst_mf_question.getGlideObject().getQuestion().getLabel(); -->
</g:evaluate>
I tried each of the commented rows in the above 1 at a time. I then tried to display using the following:
<tr>
<td class="tg-labelSrvy">${grRITM_MF_question}</td>
<td class="tg-attrSrvy" colspan="2">${grRITM.variables.rqst_mf_question.getDisplayValue()}</td>
</tr>
It ends up not displaying anything in the row in the table. It does not even display the grRITM.variables.rqst_mf_question.getDisplayValue, which tells me it does not like what was returned

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎10-25-2018 03:39 PM
All working now:
Turned out to be an extra character in the evaluate that was preventing the script from executing some of the statements.
Code
<g:evaluate>
var instanceURI = gs.getProperty('glide.servlet.uri');
var logoURI = instanceURI + 'DriveIT_CNHi_FCA_logo_small.png';
var currentDate = gs.now();
var taskID = '${sysparm_id}';
var strQuery = 'sys_idIN ';
var grTask = new GlideRecord('sc_task'); // Get the current task
grTask.get(taskID);
var grRITM = new GlideRecord('sc_req_item'); // Get the parent of the task
grRITM.get(grTask.request_item);
var taskSubType = grTask.u_task_sub_type;
var sundwnQuestionaire = taskSubType == 'cto_sundwn_questions' ? true : false;
grRITM_rqst_date_of_last_usage = grRITM.variables.rqst_date_of_last_usage.getGlideObject().getQuestion().getLabel();
grRITM_rqst_business_ok = grRITM.variables.rqst_business_ok.getGlideObject().getQuestion().getLabel();
grRITM_rqst_legacy_access_question = grRITM.variables.rqst_legacy_access_question.getGlideObject().getQuestion().getLabel();
grRITM_rqst_legacy_access_question_solution = grRITM.variables.rqst_legacy_access_question_solution.getGlideObject().getQuestion().getLabel();
<!-- G E T Q U E S T I O N L A B E L S -->
grRITM_rqst_mf_question = grRITM.variables.rqst_mf_question.getGlideObject().getQuestion().getLabel();
grRITM_rqst_up_down_stream = grRITM.variables.rqst_up_down_stream.getGlideObject().getQuestion().getLabel();
grRITM_rqst_datacenter_hosted = grRITM.variables.rqst_datacenter_hosted.getGlideObject().getQuestion().getLabel();
<!-- Application Access Variables -->
grRITM_rqst_access_removal = grRITM.variables.rqst_access_removal.getGlideObject().getQuestion().getLabel();
</g:evaluate>
The above sets the variables and below is
<div class="server_list_header"><h3>Survey Questions</h3></div>
<table class="tg">
<thead>
<tr class="pm_table_header">
<th class="sd_hdr_35_doc">Question</th>
<th class="sd_hdr_10_doc">Response</th>
<th class="sd_hdr_55_doc">Comments</th>
</tr>
</thead>
<tbody class="pm_ci_table_body">
<tr>
<td class="tg-labelSrvy">${grRITM_rqst_date_of_last_usage}:</td>
<td class="tg-attrSrvy">${grRITM.variables.rqst_date_of_last_usage.getDisplayValue()}</td>
<td class="tg-attrSrvy"></td>
</tr>
<tr>
<td class="tg-labelSrvy">Has the Business agreed to sundown?</td>
<td class="tg-attrSrvy">${grRITM.variables.rqst_business_ok.getDisplayValue()}</td>
<td class="tg-attrSrvy"></td>
</tr>
<tr>
<td class="tg-labelSrvy">Is there any requirement (e.g. business, record retention, legal hold) for users to maintain access to the legacy data?</td>
<td class="tg-attrSrvy">${grRITM.variables.rqst_legacy_access_question.getDisplayValue()}</td>
<td class="tg-attrSrvy">${grRITM.variables.rqst_legacy_acces_list.getDisplayValue()}</td>
</tr>
<tr>
<td class="tg-labelSrvy">Does the application currently have a solution to access the legacy data?</td>
<td class="tg-attrSrvy">${grRITM.variables.rqst_legacy_access_question_solution.getDisplayValue()}</td>
<td class="tg-attrSrvy"></td>
</tr>
<j:if test="${grRITM.variables.rqst_legacy_access_question_solution == 'yes'}">
<tr>
<td class="tg-labelSrvy">Outline the solution to provide access to the legacy data:</td>
<td class="tg-attrSrvy"></td>
<td class="tg-attrSrvy">${grRITM.variables.rqst_legacy_access_question_sol_yes.getDisplayValue()}</td>
</tr>
</j:if>
<j:if test="${grRITM.variables.rqst_legacy_access_question_solution == 'no'}">
<tr>
<td class="tg-labelSrvy">Specify the legacy data that must be archived:</td>
<td class="tg-attrSrvy"></td>
<td class="tg-attrSrvy">${grRITM.variables.rqst_legacy_access_question_sol_no.getDisplayValue()}</td>
</tr>
</j:if>
<tr>
<td class="tg-section" colspan="3" >General Section</td>
</tr>
<tr>
<td class="tg-labelSrvy">${grRITM_rqst_mf_question}</td>
<td class="tg-attrSrvy" colspan="2">${grRITM.variables.rqst_mf_question.getDisplayValue()}</td>
</tr>
<tr>
<td class="tg-labelSrvy">${grRITM_rqst_up_down_stream}</td>
<td class="tg-attrSrvy" colspan="2">${grRITM.variables.rqst_up_down_stream.getDisplayValue()}</td>
</tr>
<tr>
<td class="tg-labelSrvy">${grRITM_rqst_datacenter_hosted}</td>
<td class="tg-attrSrvy" colspan="2">${grRITM.variables.rqst_datacenter_hosted.getDisplayValue()}</td>
</tr>
<tr>
<td class="tg-section" colspan="3" >APPLICATION Access</td>
</tr>
<j:choose>
<j:when test="${grRITM.variables.rqst_access_removal == 'yes'}">
<tr>
<td class="tg-labelSrvy">${grRITM_rqst_access_removal}</td>
<td class="tg-attrSrvy">${grRITM.variables.rqst_access_removal.getDisplayValue()}</td>
<td class="tg-attrSrvy">${grRITM.variables.rqst_access_removal_list.getDisplayValue()}</td>
</tr>
</j:when>
<j:otherwise>
<tr>
<td class="tg-labelSrvy">${grRITM_rqst_access_removal}</td>
<td class="tg-attrSrvy">${grRITM.variables.rqst_access_removal.getDisplayValue()}</td>
<td class="tg-attrSrvy"></td>
</tr>
</j:otherwise>
</j:choose>
....
</tbody>
</table>
Sample of what if looks like: