Quantcast
Channel: Alert.js - CRM 2013-2016 Custom Alerts and Popup Dialogs JavaScript Lightbox
Viewing all articles
Browse latest Browse all 170

Commented Unassigned: Alert.show should restrain the URL to be less than 2000 characters [366]

$
0
0
I was attempting to spit out an error message from a Soap call, and the error message was longer than 2000 characters, which resulted in the url being longer than 2015 characters (maybe thats the limit for CRM online?) and errored. The Call should limit the message to less than 2000 characters, maybe by limitting to 1990, and added "-snipped-" to the end?

Without this limit, a 404 is returned.
Comments: ** Comment from web user: hulk2484 **

This is what I came up with as a first try. Not sure how to figure out what the length of something will be before encoding it:

```
var iconQs = encodeURIComponent("icon=" + (icon || "")),
titleQs = encodeURIComponent("&title=" + (title || "")),
messageQs = encodeURIComponent("&message=" + (message || ""));
var buttonsQs = "";
for (var i = 0; i < buttons.length; i++) {
buttonsQs += "&buttons[]=" + buttons[i].label;
}
buttonsQs = encodeURIComponent(buttonsQs);

if (iconQs.length + titleQs.length + messageQs.length + buttonsQs.length > Alert._maxQsLength) {
// QS is too long.
// Assume either the title or message is causing it to be too long
var max = (Alert._maxQsLength - buttonsQs.length - iconQs.length) / 2;
var snipped = encodeURIComponent("-snipped-");
var diff = 0;
if (titleQs.length > max && messageQs.length > max) {
// Shorten Both
diff = titleQs.length - title.length;
titleQs = encodeURIComponent("&title=" + title.substring(0, max - snipped.length - diff)) + snipped;
diff = messageQs.length - message.lenght;
messageQs = encodeURIComponent("&message=" + message.substring(0, max - snipped.length- diff)) + snipped;

} else if (title.length > max) {
diff = titleQs.length - title.length;
titleQs = encodeURIComponent("&title=" + title.substring(0, Alert._maxQsLength - buttonsQs.length - iconQs.length - message.length - snipped.length - diff)) + snipped;
} else {
diff = messageQs.length - message.length;
messageQs = encodeURIComponent("&message=" + message.substring(0, Alert._maxQsLength - buttonsQs.length - iconQs.length - title.length - snipped.length - diff)) + snipped;
}
}

var url = "/webresources/mag_/html/alert_dialog.html?Data=" + iconQs + titleQs + messageQs + buttonsQs;
```


Viewing all articles
Browse latest Browse all 170

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>