Reproducing the Save Business rule in SalesLogix 7.5 Web

In the SalesLogix web application architect you can create a toolbar item that has an OnClickAction of the save business rule.  With this business rule you can also specify a redirect response and a redirect page.  These are all inherent properties that you can define and make creating something like an insert form quick and easy.

But what happens if you want to do something first before calling the Save business rule?  For instance, what if you want to check a field is filled in or has a correct value?  Well to do that you can change the OnClickEvent from a Business rule to a C# snippet.  Then you can add some code, such as:

Sage.Entity.Interfaces.IAccount account = this.BindingSource.Current as Sage.Entity.Interfaces.IAccount;
if (string.IsNullOrEmpty(account.Type))
    {           
                throw new Sage.Platform.Application.ValidationException("Account Type is Required.");
    }
account.Save();
Response.Redirect(string.Format("account.aspx?entityid={0}", account.Id));

 
In the case of the code above, I am checking to see if the Account Type field is filled in.  If it is not I display a message box, if it is I proceed to call the last two lines.  These two lines act to mimic the Save business rule:
 
account.Save();

Every entity has an exposed method called Save which is the same thing as selecting the Save business rule property.

And the redirect line:

Response.Redirect(string.Format("account.aspx?entityid={0}", account.Id));

This line specifies the name of the page ("account.aspx") as well as the entityid parameter ("?entityid=") which in my code, I am passing in the Id property of my Account entity.

So that is all you need to do.  Pretty simple.  Replace two property settings for two lines of code.  Plus, this allows you to add a lot more logic than using the standard business rule available in the architect.

ABOUT THE AUTHOR

Kris Halsrud

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

1 Comment

  1. I think this is a great post from an expert and thank you very much for sharing this valuable information with us.

    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!