spModal.alert add new lines in message

triciav
Kilo Sage

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?

find_real_file.png

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');

});

 

}

}

}

 

 

1 ACCEPTED SOLUTION

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" + ...

View solution in original post

12 REPLIES 12

Maik Skoddow
Tera Patron
Tera Patron

Hi

you have to use HTML tags for formatting the message and <br> is the HTML tag for a new line.

Kind regards
Maik

OlaN
Giga Sage
Giga Sage

I also answered the follow up question the same way in the original thread... obviously not fast enough.. 🙂

OlaN - Did not mean to offend you.

 

html in client script in not working

so adding "<br>" instead on the "\n" is not working.

I posted back in the original thread.

Thank you

No worries, I'm not offended at all, I'm happy to help, anyway I can. 🙂

So your modal is working, but it's loaded when you click a button.

I'm assuming you could change the behaviour to load the modal whenever a variable changes? Have you looked at using a Catalog Client script instead?
It's hard to give good advice, since I don't have so much details on what you have to work with.

What other variables do you have on the form, how is the user supposed to interact with the form?