Displaying alerts in the SalesLogix web client with the Client Message Service

There are a myriad of ways of displaying alerts in the SalesLogix web client.  You have of course the standard javascript alert:

<script type=”text/javascript”>

function launchAnAlert() {

alert(‘A plain alert from javascript’);

}

</script>

 

This produces something very plain like this:

 Alert in SalesLogix

 

This is very simple to implement but does have some draw backs.  First the message can not really be formatted beyond just displaying some text.  A bigger issue is how some browsers handle alerts.  Some browsers have logic built in to determine if alerts are really “needed”.  They even offer the user an option to turn messages off for the page.  This is not a good thing when you are hoping to use these alerts or confirmations as part of business logic in the SalesLogix web client.

Alert in SalesLogix with Warning

 

Another option is to launch the SalesLogix DialogService Show Message from server side code.

 

<script runat=”server” type=”text/C#”>

protected void serverAlert(object sender, EventArgs e) {
  if (DialogService != null) {
    DialogService.ShowMessage(“A plain text Message “, “Message Title”);
  }
}

</script>

 

 

 

This produces a truly awful alert with not a very good user interface.  There are no buttons to click, only the small X in the corner.  This is also a huge window that can not be sized and the text is again plain text that can not be formatted.  It also is the slowest approach since it is server side code and requires a round trip to the server.

Server Side SalesLogix Alert

 

So any serious web developers know there are a lot of other choices out there.  I doubt any of those types are reading this post so I want to mention another easy way of displaying a really nice alert box in the SalesLogix web client by using the SalesLogix ClientMessageService.  This is a javascript service that is part of the SalesLogix web client.  To invoke this message box you simply need to use code like this:

<script type=”text/javascript”>

function launchCoolAlert(){
var msgSvc = Sage.Services.getService(‘WebClientMessageService’); 
msgSvc.showClientMessage(‘My title’, ‘My <i>super</i> <font color=red>SalesLogix</font> message</br>Line <b>breaks</b> too!’, ‘return false;’, ”) ;

}
</script>

This produces a well formatted alert like so:

  Client Message Service Alert in SalesLogix

 

 

Notice you can add a title and also place standard HTML markup in the message!.  That looks pretty nice, right?

 

Lets take a look at the code of the service itself.  The javascript file that runs this is located in the jscript/sage-platform directory and is called sage-platform-clientmessageservice.js.  This file is actually consolidated into the sage-plaform.js file but to see just this message service you can look at the smaller file.

 

The service itself is really simple:

 

Sage.WebClientMessageService = function(options) {
};

Sage.WebClientMessageService.prototype.hideClientMessage = function() {   
    Ext.Msg.hide();
};

Sage.WebClientMessageService.prototype.showClientMessage = function(title, msg, fn, scope) {
    if (typeof title === “object”)
        return Ext.Msg.alert(title);           
    var o = {
        title: (typeof msg === “string”) ? title : Sage.WebClientMessageService.Resources.DefaultDialogMessageTitle,
        msg: (typeof msg === “string”) ? msg : title,
        buttons: Ext.Msg.OK,
        fn: fn,
        scope: scope
    };
    Ext.Msg.show(o);   
};

Sage.Services.addService(“WebClientMessageService”, new Sage.WebClientMessageService());

 

We can see that what is actually being implement here is the ExtJS Message Box.  For details on the ExtJS message box, check out this informative post.

So there you have it, probably the best way of showing an alert in the SalesLogixweb client.  Just a little bit more code than a standard javascript alert but with much more visual control. 

A word of warning, SalesLogix v8 is making a switch over to the Dojo framework for most of the client side libraries.  Sage wants to get away from the suite of libraries it currently uses (ExtJS, YUI, jQuery) and stick to one library.  I am not sure what their plans are for legacy support of these other libraries.  Since this message service is ExtJS based it may not be available once you move to v8 but for now it is there for you to use.

 

 

 

 

ABOUT THE AUTHOR

Kris Halsrud

Kris Halsrud is a Senior Analyst / Developer for Customer FX Corporation.

1 Comment

  1. Thiago the entity model is all server side so there is no way of setting properties via client side script unless you do something like make client side Sdata calls.

    However, setting a control’s property (that is a normal bound SLX control) via javascript will allow that value to be saved to the entity via the normal save event.

    You can think of it is setting a control’s value manually via the keyboard, or in code via javascript, is identical, as far as the postback of the page to the server is concerned.

    Reply

Submit a Comment

Your email address will not be published. Required fields are marked *

Subscribe To Our Newsletter

Join our mailing list to receive the latest Infor CRM (Saleslogix) and Creatio (bpm'online) news and product updates!

You have Successfully Subscribed!