Showing a message to a user in SalesLogix Web is an easy task. It should be, right? Of course - and it is, however, you might need to know where to look to do it. This post will take a look at how to do this from both a Code Snippet Action and a C# Snippet Action.
Showing a message in the web client, like using MsgBox from a LAN client script, requires use of the DialogService. The DialogService has a ShowMessage method you can use to display a message to the user.
From a Code Snippet Action
To use the DialogService from a Code Snippet Action, you need to use the form's WorkItem reference that is passed in to the code action. This will allow you to get access to the DialogService.
// Get a reference to the DialogService Sage.Platform.WebPortal.Services.IWebDialogService dialogService = form.WorkItem.Services.Get<Sage.Platform.WebPortal.Services.IWebDialogService>(); // Now show a message to the user dialogService.ShowMessage("You must first do something."); |
Easy enough, now let's take a look at how to do this from a C# Snippet Action.
From a C# Snippet Action
From a C# Snippet Action things a a little different. As I mentioned before, code in a C# Snippet Action gets placed directly on the SmartPart (the ASCX UserControl). The code is inline on the deployed ASCX file itself. The SmartPart inherits from EntityBoundSmartPartProvider which eventually inherits from Sage.Platform.WebPortal.SmartParts.SmartPart which has a built-in DialogService reference. What this means is that you no longer have to get a reference to the DialogService yourself, you just use the one you already have.
// Show a message to the user this.DialogService.ShowMessage("You must first do something."); |
Either way, whether you're in a C# Snippet, or the Code Action things are all nice and simple, as it should be.