Please help with creating a line break using GlideModal.

Erica2
Tera Contributor

 

Hello, 

 

I have a catalog client script that displays a message when a variable changes.

I'm trying to insert a new line in the Title between 'the' and 'IT Service Desk,' but I can't figure out how to do it.

 

 

Erica2_1-1730325126182.png

 

This is not a complete code.  Thank you

 

gm.setTitle("Task Closure and New Assignment");
        gm.setPreference("title", "This task will be closed, and a new one will be created and assigned to the IT Service Desk. Would you like to proceed with this?");
        gm.setPreference("warning", "false");
        gm.setPreference("onPromptComplete", function() {
}

 

 

 

2 ACCEPTED SOLUTIONS

Runjay Patel
Giga Sage

Hi @Erica2 ,

 

You can create ui page and call GlideModel.

 

 

var confirm = new GlideModal('confirm_p2');
	confirm.setTitle('Confirmation');
	confirm.setPreference("onPromptComplete", "ok");
	confirm.setPreference("onPromptCancel", "cancel");
	confirm.render();

 

 

In ui page you can design like below.

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">
<g:ui_form onsubmit="return invokeConfirmCallBack('ok');">
<table border="0" width="100%">
	<tr><td/>
		
		<p style="font-size: larger;">This task will be closed, and a new one will be created and assigned to the </p>

		<p style="font-size: larger;">IT Service Desk. Would you like to proceed with this? </p>
		
		
	<td/></tr>
        
		<tr>
     	<td nowrap="true"><g:no_escape>${title}</g:no_escape></td>	
	</tr>
        <tr><td/><td/></tr>
        <tr>
            <td  style="padding: 10px;" colspan="2" align="right">
                <g:dialog_buttons_ok_cancel 
                   ok="invokePromptCallBack('ok');" 
                   ok_type="button" 
                   cancel="invokePromptCallBack('cancel')" 
                   cancel_type="button" />
            </td>
        </tr>	
</table>
</g:ui_form>
</j:jelly>

 

Client script

 

function invokePromptCallBack(type) {
    var gdw = GlideDialogWindow.get();
    if (type == 'ok') {
       var f = gdw.getPreference('onPromptComplete');
		gsftSubmit(null, g_form.getFormElement(), 'sysverb_insert');
	}
   
      
    gdw.destroy();
    return false;
}

 

 

RunjayPatel_0-1730538334621.png

 

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

 

 

 

View solution in original post

Hi @Erica2 ,

 

Yes you can do that, make changes in your ui page like below.

<?xml version="1.0" encoding="utf-8" ?>
<j:jelly trim="false" xmlns:j="jelly:core" xmlns:g="glide" xmlns:j2="null" xmlns:g2="null">
<g:ui_form onsubmit="return invokeConfirmCallBack('ok');">
<table border="0" width="100%">
	<tr><td/>
		
		<p style="font-size: larger;">This task will be closed, and a new one will be created and assigned to the </p>

		<p style="font-size: larger;">IT Service Desk. Would you like to proceed with this? </p>
		
		
	<td/></tr>
        
		<tr>
     	<td nowrap="true"><g:no_escape>${title}</g:no_escape></td>	
	</tr>
        <tr><td/><td/></tr>
        <tr>
            <td  style="padding: 10px;" colspan="2" align="right">
                <!-- <g:dialog_buttons_ok_cancel 
                   ok="invokePromptCallBack('Yes');" 
                   ok_type="button" 
                   cancel="invokePromptCallBack('cancel')" 
                   cancel_type="button" /> -->
				  
		<div class="modal-footer">
				   
	<span class="pull-right">
		<button class="btn btn-default" id="cancel_button" onclick="invokePromptCallBack('cancel')" style="min-width: 5em;" title="" type="submit">
			No
		</button>
		<button class="btn btn-primary" id="ok_button" onclick="invokePromptCallBack('ok')" style="min-width: 5em;" title="" type="submit">
			Yes
		</button>
	</span>
</div>
            </td>
        </tr>	
</table>
</g:ui_form>
</j:jelly>

 

-------------------------------------------------------------------------

If you found my response helpful, please consider selecting "Accept as Solution" and marking it as "Helpful." This not only supports me but also benefits the community.


Regards
Runjay Patel - ServiceNow Solution Architect
YouTube: https://www.youtube.com/@RunjayP
LinkedIn: https://www.linkedin.com/in/runjay

-------------------------------------------------------------------------

 

 

View solution in original post

10 REPLIES 10

Murthy Ch
Giga Sage

Hello @Erica2 

As far as I know this is something we cannot acheive this because title accepts only string where it doesn't support multiline text formatting so you'll need to work within those constraints. Unfortunately, if the title doesn't allow for line breaks or HTML, your options will be limited.

 

 

Thanks,
Murthy

Hitoshi Ozawa
Giga Sage
Giga Sage

@Erica2 How about changing a title string a little bit.

HitoshiOzawa_0-1730363612597.png

	var gm = new GlideModal('glide_confirm_standard', true);
    gm.setTitle("Task Closure and New Assignment");
    gm.setPreference("title", 'Clicking on the OK button will close this task and create a new task  assigned to the IT Service Desk. Would you like to proceed with this?');
	gm.setPreference("warning", "false");
    gm.setPreference('onPromptComplete', complete);

Thank you for your suggestion @Hitoshi Ozawa 

 

That was a clever idea, and it works perfectly for this situation. However, if there is a way to insert a new line using code, I would like to learn it, as there may be times when we will need to use it.

@Erica2 Unfortunately no with glide_confirm_standard. ServiceNow is escaping and concatenating the string and putting it in double quotes.

Would have to clone and edit the UI page. Won't recommend it too much because it may stop working after versioning up ServiceNow.