Line breaks not coming over into UI Pages
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2020 10:45 AM
We have a bit of customization built into our incident module to help with Major incidents notifications. We have a UI action that opens a UI page. On the UI page, we have a field that copies the values from a field on the incident form(u_mi_email_body). The problem that we are having is that the value is coming over, but its not picking up line breaks.
If the incident form says
Line 1
Line 2
It will come over as Line1Line 2
Below is the line of code that copies that value
<j:set var="jvar_email_body" value="${RP.getWindowProperties().get('u_mi_email_body')}" />
<g:ui_multiline_input_field label="Email Body" name="email_body" value='${jvar_email_body}' size="50" />
How do I add a line break within this code to allow the UI page to pick up the line breaks from the incident form?
Please let me know if I need to share more code.
Thank you
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2020 11:32 AM
Hi aj_becker,
Try this:-
<tr>
<td style="white-space:pre-line">
${jvar_street}
</td>
</tr>
For more information go through following link:
Mark Correct & Helpful if this solves your issue.
Thanks,
Vishakha Pradhan
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2020 11:43 AM
This is just bring over the value of the field. Still not correctly. Where should I put this in my code?
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-26-2025 12:48 PM
this worked for me, thank YOU!
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-18-2020 12:09 PM
To provide more information.
UI Action that calls the UI Page Script:
//Client-side 'onclick' function
function sendEmail(){
var dialog = new GlideDialogWindow("notify_major_inc_popup");
dialog.setSize(400,200);
dialog.setTitle("Send Major Incident Notification?");
dialog.setPreference("short_description", g_form.getValue("short_description"));
dialog.setPreference("incident_number", g_form.getValue("number"));
dialog.setPreference("u_major_incident_state", g_form.getValue("u_major_incident_state"));
dialog.setPreference("u_mi_work_performed", g_form.getValue("u_mi_work_performed"));
dialog.setPreference("u_mi_email_body", g_form.getValue("u_mi_email_body"));
dialog.setPreference("u_business_services", g_form.getValue("u_business_services"));
dialog.setPreference("sys_id", g_form.getUniqueValue());
dialog.render();
//action.setRedirectURL(current);
}
UI Page HTML
<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<!-- Get values from dialog preferences passed in -->
<j:set var="jvar_incident_number" value="${RP.getWindowProperties().get('incident_number')}" />
<j:set var="jvar_sys_id" value="${RP.getWindowProperties().get('sys_id')}" />
<j:set var="jvar_u_business_services" value="${RP.getWindowProperties().get('u_business_services')}" />
<g:ui_form>
<j:set var="jvar_mi_state" value="${RP.getWindowProperties().get('u_major_incident_state')}" />
<g:ui_multiline_input_field label='Email Subject' name="mi_state" value ='${jvar_mi_state}' table='incident' field='u_major_incident_state' />
<center>
<input type="hidden" name="cancel_or_send" id="cancel_or_send" value=""/>
<input type="hidden" name="incident_sys_id" value="${jvar_sys_id}"/>
<input type="hidden" name="u_business_services_form_input" value="${jvar_u_business_services}"/>
<j:set var="jvar_email_body" value="${RP.getWindowProperties().get('u_mi_email_body')}" />
<g:ui_multiline_input_field label="Email Body" name="email_body" value='${jvar_email_body}' field='u_mi_email_body' size="50" />
<g:dialog_buttons_ok_cancel ok_text="Send" ok="return send();" cancel="return cancel();"/>
</center>
</g:ui_form>
</j:jelly>
Client Script
function cancel() {
var c = gel('cancel_or_send');
c.value = "cancel";
//GlideDialogWindow.get().destroy();
return true;
}
function send() {
var c = gel('cancel_or_send');
c.value = "send";
g_form.save();
return true;
}
Processing Script
if(cancel_or_send == "cancel") {
gs.addErrorMessage('Notification cancelled');
}
var log = [];
log.push("RDS\n");
if(cancel_or_send == "send") {
var gr = new GlideRecord('incident');
gr.get(incident_sys_id);
log.push("BEFORE setValue -> " + gr.getValue('u_business_services'));
gr.setValue('u_business_services', u_business_services_form_input);
gr.update();
log.push("AFTER setValue -> " + gr.getValue('u_business_services'));
// look up the email addresses for the app services
var gr_app_svcs = new GlideRecord('cmdb_ci_service');
gr_app_svcs.addQuery('service_classification','=','Application Service');
var support_groups_arr = [];
// for each app service referenced on the Incident, get them into their own GR
var str_array = gr.u_business_services.toString().split(',');
for(var i = 0; i < str_array.length; i++) {
if (i == 0) {
var qc = gr_app_svcs.addQuery('sys_id', str_array[i]);
} else {
qc.addOrCondition('sys_id', str_array[i]);
}
}
gr_app_svcs.query();
// put the support group sys_ids into an array
while (gr_app_svcs.next()) {
support_groups_arr.push(gr_app_svcs.support_group.toString());
}
// for each sys_id, fire an event to sent a notification
for(var i = 0; i < support_groups_arr.length; i++) {
gs.eventQueue('incident.notification.major', gr, support_groups_arr[i]);
}
gs.addInfoMessage('Major Incident Notification Sent');
gr.setValue('u_major_incident_state', mi_state);
gr.setValue('u_mi_email_body', email_body);
gr.update();
}
// Redirect user back to Incident form
response.sendRedirect('incident.do?sys_id='+incident_sys_id);
Image below shows the line break (on the right) coming from the incident vs the UI page and it not recognizing the line break