Skip to main content
Solved

New Line and Tab for Message in Alert box

  • Jul 15, 2025 4:59 PM UTC
  • 6 replies
  • 91 views

JuniSihombing
Hero (Customer)
Forum|alt.badge.img+11

Hi,

I am aiming to show message in alert box like this:

 

 

I have tried to use code like this:

			var resultTasks = getDBValues('C_GET_OPEN_PROD_PM_SCHED_TASK', [productId, productPmId]);
if (size(resultTasks)>0) {
// NR > 0 -- message to close/cancel the open task
message = message + getMessage('cPleaseCloseTask' , 'Information');
message = message + "\n";
message = message + getMessage('cBeforeChangeVCF', 'Information');
message = message + "\n" + "\n";
message = message + getMessage('RequestId' , 'Label');
message = message + "\t" ;
message = message + getMessage('TaskId' , 'Label');
message = message + "\t" ;
message = message + getMessage('TaskStatus' , 'Label');
message = message + "\n";

for (i = 0; i<size(resultTasks); ++i) {
var resultTask = resultTasks[i];
line = line + resultTask.request_id;
line = line + "\t";
line = line + resultTask.task_id;
line = line + "\t";
line = line + resultTask.task_status;
line = line + "\n";
}
alert(message + line);
return false;

 

or using code like this:

			var resultTasks = getDBValues('C_GET_OPEN_PROD_PM_SCHED_TASK', [productId, productPmId]);
if (size(resultTasks)>0) {
// NR > 0 -- message to close/cancel the open task
message = getMessage('cPleaseCloseTask','Information')+"\n"+getMessage('cBeforeChangeVCF','Information')+"\n"+"\n"+getMessage('RequestId','Label')+"\t"+getMessage('TaskId','Label')+"\t"+getMessage('TaskStatus','Label')+ "\n";

for (i = 0; i<size(resultTasks); ++i) {
var resultTask = resultTasks[i];
line = line + resultTask.request_id;
line = line + "\t";
line = line + resultTask.task_id;
line = line + "\t";
line = line + resultTask.task_status;
line = line + "\n";
}
alert(message + line);
return false;

 

The result does not show the new line and tab and it show the “\t” in the message.

Do you know how to create new line (CR) and tab in alert message?

 

Looking forward to your enlightenment.

 

Cheers,
~Juni

 

 

Best answer by Shneor Cheshin

​@JuniSihombing 

Yes, I've worked on this quite a bit in the past and couldn't get it working either.

Sorry, you will need to adhere to the alert message limitations or find an alternative solution.

Cheers!

 

View original

6 replies

Shneor Cheshin
Superhero (Employee)
Forum|alt.badge.img+28
  • Superhero (Employee)
  • Jul 16, 2025 7:06 AM UTC

Hi ​@JuniSihombing 

Line break ot tab break is not supported in the alert messages.

Just a wild idea, I did not try this.

Try creating the message value in a DB table or view, which supports line breaks and then show it in the alert message.

Please share the results.

Cheers!


JuniSihombing
Hero (Customer)
Forum|alt.badge.img+11
  • Author
  • Hero (Customer)
  • Jul 16, 2025 7:20 AM UTC

Hi ​@Shneor Cheshin,

thank you for your feedback.

 

Let me try your suggestion, and come back with the results.

 

Cheers,

~Juni


JuniSihombing
Hero (Customer)
Forum|alt.badge.img+11
  • Author
  • Hero (Customer)
  • Jul 16, 2025 1:05 PM UTC

Hi ​@Shneor Cheshin,

unfortunately it doesn’t work either.

If you are interested in what’s been done, here’s the snippets of the code:

 

...
message = message + line;

var alertMessage = getDBValues('C_GET_MESSAGE',[message])[0];
alert(alertMessage.message);

Client Script SQL = C_GET_MESSAGE:

SELECT 
REPLACE(REPLACE('{0}', '\n', CHAR(13) + CHAR(10)), '\t', CHAR(9)) message

 

Result:

 

It seems the new line/tab breaks are trimmed in a message.

I tried to create a custom message for the whole message containing new line, in the message in alert box does not show the new line break.

 

 

 

 


Shneor Cheshin
Superhero (Employee)
Forum|alt.badge.img+28
  • Superhero (Employee)
  • Answer
  • Jul 16, 2025 10:57 PM UTC

​@JuniSihombing 

Yes, I've worked on this quite a bit in the past and couldn't get it working either.

Sorry, you will need to adhere to the alert message limitations or find an alternative solution.

Cheers!

 


AdrianEgley
Hero (Customer)
Forum|alt.badge.img+14
  • Hero (Customer)
  • Jul 17, 2025 4:16 PM UTC

​@JuniSihombing 

Could you use something like padEnd?

How would something like that display?

 

var resultTasks = getDBValues('C_GET_OPEN_PROD_PM_SCHED_TASK', [productId, productPmId]);

if (resultTasks.length > 0) {

    var message = "";

    var line = "";

    message += getMessage('cPleaseCloseTask', 'Information') + "\n";

    message += getMessage('cBeforeChangeVCF', 'Information') + "\n\n";

    message += getMessage('RequestId', 'Label').padEnd(20, ' ');

    message += getMessage('TaskId', 'Label').padEnd(20, ' ');

    message += getMessage('TaskStatus', 'Label') + "\n";

    for (var i = 0; i < resultTasks.length; ++i) {

        var resultTask = resultTasks[i];

        line += resultTask.request_id.toString().padEnd(20, ' ');

        line += resultTask.task_id.toString().padEnd(20, ' ');

        line += resultTask.task_status + "\n";

    }

    document.getElementById("taskOutput").textContent = message + line;

    document.getElementById("taskModal").style.display = "block";

    return false;

}


JuniSihombing
Hero (Customer)
Forum|alt.badge.img+11
  • Author
  • Hero (Customer)
  • Jul 21, 2025 10:33 AM UTC

Hi ​@AdrianEgley ,

Thank you for your suggestion.

 

It seems the padEnd function is not supported in FSM client script.

I got this error message

 

 

Cheers,

~Juni