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

OlaN,

 

This is a catalog item and the user has an option to select from

Create a New Conference

Modify Existing

Cancel Conference

 

When they Select Create New I need to show the list of existing Conferences in a Popup Message instructing them not to create a new conference if one already exists.

I tried in the Client script to use spModal alert but I was not able to get the html for a line break to work.

From what I can tell html code in client scripts does not work

So I went down the path of a widget to try an achieve the same thing.

 

See below my Widget information.

Bottom Line is I need to show a popup with the existing Conferences with a nice popup

The normal alert works but I want to be able to present a nicer UI for the end users

Thank you so Much!

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

OlaN,

 

Ok I will try that now and let you know.

Then I can just use the client script which would be ideal.

Thank you

OlaN,

 

Thank you so much!!! The <br> in the script include was the key!!!

The client script is working now !! 🙂 Yeaaaaa

find_real_file.png

OlaN,

 

Thank you so much!!! The <br> in the script include was the key!!!

The client script is working now !! 🙂 Yeaaaaa