Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Wednesday, August 13, 2025 
 
slxdeveloper.com Community Forums  
   
The Forums on slxdeveloper.com are now retired. The forum archive will remain available for the time being. Thank you for your participation on slxdeveloper.com!
 Web Forums - SalesLogix Web Platform & Application Architect
Forum to discuss the use of the SalesLogix Web Platform, Client and Customer Portals, and the Application Architect (For version 7.2 and higher only). View the code of conduct for posting guidelines.
Forums RSS Feed


 Back to Forum List | Back to SalesLogix Web Platform & Application Architect | New ThreadView:  Search:  
 Author  Thread: this.BindingSource in v7.5 web custom code snippets
SLX...
Posts: 29
 
this.BindingSource in v7.5 web custom code snippetsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 09 Oct 08 2:32 PM
We have been upgrading some code form v7.2 and noticed that the 7.5 implementation of code snippets is different.

In 7.2 you were always supposed to check to ensure that this.BindingSource was not null before using it or trying to cast it to an entity type. However, in 7.5, this.BindingSource is NEVER null. It appears that this.BindingSource is initialized and all the properties of it are set to null.

Does anyone have suggestions on how to handle this in v7.5? We've gone through the 7.2 web coding training, but that's all out the window now. What a waste!

Thanks in advance.
[Reply][Quote]
Stephen Redmond
Posts: 190
 
Re: this.BindingSource in v7.5 web custom code snippetsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 10 Oct 08 3:27 AM
Would checking this.BindingSource.Current work for you?

Can I ask you to change your name please. This is a generally friendly group and I for one prefer to deal with real people and not aliases.

Regards,


Stephen
www.slxmaster.com

[Reply][Quote]
slxguy
Posts: 71
 
Re: this.BindingSource in v7.5 web custom code snippetsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 10 Oct 08 8:03 AM
Quote:
Originally posted by Stephen Redmond

Would checking this.BindingSource.Current work for you?


It's the same issue here. The object itself is never actually null. The object is being initialized by slx and every property associated with it is null. It's like they created a default constructor just to make a completely empty object. Seems sort of weird because it makes checking if your binding source or current binding source is null completely useless.
[Reply][Quote]
Stephen Redmond
Posts: 190
 
Re: this.BindingSource in v7.5 web custom code snippetsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 10 Oct 08 8:45 AM
I'm confused.

How is this a problem. What, exactly, are you trying to achieve and under what circumstances?

The fact that this.BindingSource is always populated is, to me, correct. If "this" is a bound page, then it will always have some kind of BindingSource, no? It is still valid to check that the BindingSource is null - it is good practice - but I don't see the problem.

Again, what, exactly, is the problem?


Stephen


[Reply][Quote]
SLX...
Posts: 29
 
Re: this.BindingSource in v7.5 web custom code snippetsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 10 Oct 08 9:15 AM
Perhaps, it's more of a semantic issue than a practical issue. Here's a sample piece of code:

if (this.BindingSource.Current != null) {
Sage.Entity.Interfaces.IAccount acct =
this.BindingSource.Current as Sage.Entity.Interfaces.IAccount;

// get account name - could crash
String s = acct.Account;
}

The problem is that the object model will NEVER set this.BindingSource.Current to null (even though it's entity is really null). So, it will always allow you to cast this.BindingSource.Current as the interface that it is (IAccount in this example). Now, if you debug this code, you can find that referencing a property of this interface will return a null reference error.

Now, this seems silly to me - if the entity is really null, instead of allowing you to type cast it and attempt to reference a property, wouldn't you think that this.BindingSource.Current would be null? So if you pass the this.BindingSource.Current != null test, you should feel safe type casting and then referencing all the fields in the entity that have values within.

[Reply][Quote]
Stephen Redmond
Posts: 190
 
Re: this.BindingSource in v7.5 web custom code snippetsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 10 Oct 08 11:14 AM
Hi,

If this.BindingSource.Current isn't an Account entity then your code line:

Sage.Entity.Interfaces.IAccount acct =
this.BindingSource.Current as Sage.Entity.Interfaces.IAccount;

Will result in acct = null. This is the scenario that will occur when you use the same form to edit a related table for multiple entities. You cast Current and see which one isn't null to work with.

Your next line of code should be:


if (acct != null)
{
// get account name - could crash
String s = acct.Account;
}


Stephen
www.slxmaster.com
[Reply][Quote]
SLX...
Posts: 29
 
Re: this.BindingSource in v7.5 web custom code snippetsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 10 Oct 08 11:57 AM
I wish this were true.

Acct will NEVER be null. All of the properties of acct may be null, but the actual acct object there will never be null. It's really screwy and does not make sense.

Try adding a custom code snippet in 7.5 app architect for the onload action of adding a new account. Plug this code in and check it out. It's pretty disturbing.

[Reply][Quote]
Stephen Redmond
Posts: 190
 
Re: this.BindingSource in v7.5 web custom code snippetsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 10 Oct 08 1:39 PM
OK, I vaguely understand what you are getting at.

There isn't a problem here. When you add a new Account, the system creates a new instance of the object with no values (how could it know what to fill them with). It is not that they system is populating the properties with Null, it is just not populating anything.

So the scenario that you have mentioned is not disturbing at all - it is FAD. Otherwise, how would you propose to write code to populate a default value?

Does that help ease your distubia?


Stephen
www.slxmaster.com
[Reply][Quote]
SLX...
Posts: 29
 
Re: this.BindingSource in v7.5 web custom code snippetsYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 10 Oct 08 1:43 PM
I had a cup of coffee today and I'm on a no-caffeine diet - my disturbia cannot be quelled.

Thanks for some insight. I think I just jumped off the deep end.
[Reply][Quote]
 Page 1 of 1 
  You can subscribe to receive a daily forum digest in your user profile. View the site code of conduct for posting guidelines.

   Forum RSS Feed - Subscribe to the forum RSS feed to keep on top of the latest forum activity!
 

 
 slxdeveloper.com is brought to you courtesy of Ryan Farley & Customer FX Corporation.
 This site, and all contents herein, are Copyright © 2025 Customer FX Corporation. The information and opinions expressed here are not endorsed by Sage Software.

code of conduct | Subscribe to the slxdeveloper.com Latest Article RSS feed
   
 
page cache (param): 8/13/2025 3:08:37 PM