- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2022 10:00 AM
I had a previous question and was able to get some assistance with that.
However I am now trying to get the spModal alert to display each of the answers from my GlideAjax onto individual lines
I was able to look at the link and get the spModal,
However I am having the same issue now with the spacing
How do I get this to be with line breaks
So for each of the Conference Names I need them to be on their own line
List of Conferences already registered
My Conference
My New Event
Test
etc.. so the below would have each conference name on its own line?
function onChange(control, oldValue, newValue, isLoading) {
if (isLoading || newValue == '') {
return;
}
var ga = new GlideAjax('ConfAjaxUtils'); //x_btig_bookings.ChoiceAvailable
ga.addParam('sysparm_name', 'getExisting');
ga.addParam('sysparm_table', "u_conferences");
ga.getXML(getresponse);
function getresponse(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
if (answer) {
var names = + '\nng =onference Names " + '\n;' + answer);
spModal.open({
"title":" + answer);
spModal.open({
"title": "Exisitng Conference Names",
"message": "List of Conferences that have already been registered. " + names,
"buttons" : [
{label: "✘ Cancel New Registration" , primary: true},
{label: "✔ Register New Conference" , cancel: true}
],
"backdrop" : "static",
"keyboard": false
}).then(function(answer){
//g_form.setValue('license_type' , 'free');
});
}
}
}
Solved! Go to Solution.
- Labels:
-
Scripting and Coding

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-21-2022 06:39 AM
I see.
I tried the approach with the spModal and the way I got it to work, was to return all the data with line breaks, formatted as HTML, from the script include.
Can you try it that way?
So the script include should return a text that looks like this:
"Conference name 1" + "<br>" + "Conference name 2" + "<br>" + ...
In my previous response you got it working with an alert, but the difference is that the alert handles newlines differently from the spModal, so it should have text as this:
"Conference name 1" + "\n" + "Conference name 2" + "\n" + ...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-20-2022 03:27 PM
I still need some help on this please:
How can I get this to load when the variable changes without the user having to click the "Check existing Conferences button" ?
So when the user changes the variable to New Conference I need to have the spModal popup without the user having to click anything.
Thank you so much!!
This is my Catalog Widget:
HTML:<button ng-click="c.onConfirmEx()" class="btn btn-default">
Check - Existing Conferences
</button>
<span>{{c.confirmed}}</span>
This is my Client Controller:
function($scope, $rootScope,$uibModal, $location,$window,spUtil,spModal) {
var c = this;
c.onConfirmEx = function() {
spModal.open({
"title": "List of Conferences that have already been registered",
"message": "Do not Register a Confernce that already exists. Use the Modify Option instead. "+"<br>"+c.data.got,
"buttons": [{
label: "✘ Cancel New Registration",
primary: true
},
{
label: "✔ Register New Conference",
cancel: true
}
],
"backdrop": "static",
"keyboard": false
}).then(function(confirmed) {
c.confirmed = confirmed;
//g_form.setValue('license_type' , 'free');
});
}
}
This is my Server Script:
(function() {
/* populate the 'data' object */
/* e.g., data.table = $sp.getValue('table'); */
var confItems = [];
var table = 'u_conferences';
var elm = 'u_conference_name';
var choicesGR = new GlideRecord('sys_choice');
choicesGR.addQuery('table', table);
choicesGR.addQuery('element', elm);
choicesGR.query();
var names = '';
while (choicesGR.next()) {
names += choicesGR.getValue('label')+"<br>";
data.got = names;
}
})();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-11-2022 07:21 AM
The basic of style sheet.
Servicenow : Client script
var names ='<pre>'+ '\nng =onference Names " + '\n;' + answer+'</pre>;
Servicenow : CSS file.
pre {
width: 100%;
padding: 0;
margin: 0;
overflow: auto;
overflow-y: auto;
height:222px;
font-size: 14px;
line-height: 20px;
border: 0px solid #777;
background-color: #ffffff;
font-family: "Kurious Looped";
font-weight: 300;
font-style: normal;
font-display: swap;
tab-width: 4;
white-space: pre-wrap; /* css-3 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word;
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-25-2025 08:54 AM
you have to use HTML tags for formatting the message and <br> is the HTML tag for a new line.
Regards,
Raje