Login / Register  search  syndication

          Ryan Farley's Blog

Ryan Farley on .NET Development with a focus on CRM Development for SalesLogix

Showing a Message to the User from a Code Snippet Action in SalesLogix Web

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.

What's This?
Bookmark and Share

About Ryan Farley

   Ryan Farley is the Director of Development for Customer FX Corporation and the creator of slxdeveloper.com.


Related Content
   Adding an assembly reference to code files in the SalesLogix Application Architect
Often when adding custom code to SalesLogix you need to reference Assemblies that are not included by def
Posted on Mar 15, 2010 by Kris Halsrud to Kris Halsrud's Blog
 
   SalesLogix Web Client- Marketing Campaigns Part I [Video]
In this video webinar the Marketing Professional will learn how to create a New Marketing Campaign in Sal
Posted on Mar 15, 2010 by Dale Richter to SalesLogix Training
 
   Launching a report from a button in the SalesLogix web client
Starting in SalesLogix 7.5.1, Sage released an undocumented Reporting enhancement that allowed for intera
Posted on Mar 12, 2010 by Kris Halsrud to Kris Halsrud's Blog
 
   Hiding Opportunities in the SalesLogix web client
Occasionally we have clients who do not use the Opportunity components of the SalesLogix web client. 
Posted on Mar 10, 2010 by Kris Halsrud to Kris Halsrud's Blog
 
   Searching for Matching Records in the SalesLogix Web Client
In this short video the user will learn how to search for matching records while adding new records to th
Posted on Mar 10, 2010 by Dale Richter to Tech Talk
 
Comments

 

mikeboysen@hotmail.com said:

Ryan,

Wow. Just in the nick of time. I don't know where you came up with this idea? Really! :)

Question: Is there something about the ShowMessage method that will not allow me to incorporate vbCrLf or Chr(10) & Chr(13) into the message for separating lines? My message is getting strung together all on the same line

December 11, 2009 7:17 AM
 

Ryan Farley said:

Thanks Mike. In the web, your message is rendering as HTML, so you *can* include HTML in the message (so <br> for line breaks). A message like this is valid:

dialogService.ShowMessage("This is <b>bold</b>. This is <i>italics</i>.<br><br>This is on a new line, etc");

-Ryan

December 11, 2009 8:45 AM
 

Steve said:

Ryan,

Interesting idea - thanks...

Is there a way to use this technique for events or business rule methods?

I tried it out, but can't get it to compile. It appears that "this" and "form" are not available for use in events or business rules.

Thanks!

January 8, 2010 10:41 AM
 

Ryan Farley said:

Hi Steve,

The whole idea of business rules is that the rule is a separation of logic from the UI. The rule operates at the entity level, not on the UI. A rule is better used to return some value like a boolean, leaving the prompting of some message to the UI layer.

Eventually (in the very near future), you'll be able to invoke business rules from SData as well, which obviously could cause problems if you did UI interaction type of things in the rule.

So, back to your question, no, you can't (and really shouldn't anyway) do this sort of thing inside of a business rule. Instead, have your rule return some value and then use a DialogAction or in code display the message based on the returned value.

-Ryan

January 8, 2010 10:51 AM

Leave a Comment

(required)  
(optional)
(required)  
Add
All contents Copyright © 2010 Customer FX Corporation
Customer FX Corporation
2324 University Avenue West, Suite 115
Saint Paul, Minnesota 55114
Tel: 800.728.5783

  Follow @CustomerFX on twitter
Follow the best news, tips, and articles
  Subscribe to Customer FX on youtube
Watch SalesLogix tutorial videos from Customer FX
Login / Register