Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Sunday, February 23, 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: Which Usings to Use?
Dan Carvin
Posts: 227
 
Which Usings to Use?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Sep 08 11:12 AM
When adding C# code to a business rule or even, how do you determine which assemblies you need to add in the Usings section?
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Which Usings to Use?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Sep 08 11:19 AM
It depends on what you code requires. If you're just checking entity properties and making decisions etc then you wouldn't need to add any. A better question would be to describe what you want to do in a business rule and your code, then we could describe what usings would be required for that code.
[Reply][Quote]
Dan Carvin
Posts: 227
 
Re: Which Usings to Use?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Sep 08 12:07 PM
I want to change the default values in an onCreate event. Using Reflector, I've found the OOTB code in an onCreate that sets the values. I'd like to remove the OOTB onCreate step and replace it with my own (copy & paste with different values), but I haven't been successful yet, and Reflector doesn't seem to display the usings.

[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Which Usings to Use?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Sep 08 12:18 PM
What you're describing doesn't really have anything to do with usings. The using directives are just a way of shortening your code, so you don't have to type in the fully qualified name and instead can just type in the class name.

If you want to change default values in an OnCreate event, just follow up the OOTB code with a post event that changes the values to what you want.

If you have specific code you want to use in the event then usings won't be enough. You will likely have to add references too. If you post the code here we could help you start to track down what is need to use it.
[Reply][Quote]
Dan Carvin
Posts: 227
 
Re: Which Usings to Use?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Sep 08 1:57 PM
All I've done is copy the code from Reflector, copy it into a new step, and change a True to False, and removed a date assignment that I don't want set yet.

When I build the site, I get errors that the Entity name and "GetCurrentUser" does not exist in the current context.

[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Which Usings to Use?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Sep 08 2:09 PM
Let's step back a bit and ignore what usings are needed for what code.

What exactly are you trying to do? Can you describe what you want to have happen?
[Reply][Quote]
Dan Carvin
Posts: 227
 
Re: Which Usings to Use?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Sep 08 2:42 PM
The onCreate for ReceivedReturnProduct record runs the following code:

returnReceivedProduct.Received = true;
returnReceivedProduct.ReceivedBy = GetCurrentUser();
returnReceivedProduct.Receiveddate = new DateTime?(DateTime.UtcNow);

I want to change this to

returnReceivedProduct.Received = false;
returnReceivedProduct.ReceivedBy = GetCurrentUser();
//returnReceivedProduct.Receiveddate = new DateTime?(DateTime.UtcNow);

[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Which Usings to Use?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Sep 08 3:06 PM
Ok. That clears things up. The great thing about the new SLX architecture is that the events can be layered. That is, let the OOTB code do what it wants, then you layer your code on top of that to change it to how you want it.

The code you posted is in the primary step of the OnCreate event. Leave that alone. All you need to do is add a post step with the code to set the Received property to false. When it runs, the OOTB code will set the property to true when the ReceivedReturnProduct is created, but right after that your code will follow and immediately set it to false.

Does that make sense?
[Reply][Quote]
Dan Carvin
Posts: 227
 
Re: Which Usings to Use?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Sep 08 3:57 PM
Yes, but...

My code is in OnCreateStep1 which appears after OnCreate. I'm still getting "ReceivedReturnProduct does not exist in the current context" when I build the site. I tried it using both onCreateStep1 below the OOTB OnCreate and as a PostCreate step.
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Which Usings to Use?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Sep 08 4:17 PM
Some things to keep in mind.

1) There can only be 1 active primary step in an event. This means, if you've added one below the existing OOTB one then yours will be active and the OOTB one will not. You should only add a primary step to an OOTB entity if you intend to completely replace the OOTB code - this is seldom, if ever, necessary. Add steps to OOTB entities as post steps (see #2)

2) Post steps can have several active steps. These will fire in succession in the order listed.

3) C# code is case-sensitive. Make sure the case of the ReceivedReturnProduct entity passed into the step matches exactly in your code. I would guess that it is not "ReceivedReturnProduct", but more likely passed in as "receivedreturnproduct".

If none of the above helps, post your entire code here (including the method signature).

-Ryan
[Reply][Quote]
Dan Carvin
Posts: 227
 
Re: Which Usings to Use?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Sep 08 5:12 PM
Here's a copy & paste of the OnCreate from Relector:

public static void OnCreate(IReturnReceivedProduct returnReceivedProduct)
{
returnReceivedProduct.Received = true;
returnReceivedProduct.ReceivedBy = GetCurrentUser();
returnReceivedProduct.Receiveddate = new DateTime?(DateTime.UtcNow);
}

Here's a copy & paste from my post-Execute step:

#region Usings
using System;
using Sage.Entity.Interfaces;
using Sage.Form.Interfaces;
#endregion Usings

namespace Sage.BusinessRules.CodeSnippets
{
public static partial class ReturnReceivedProductBusinessRules
{
public static void OnCreateStep1( IReturnReceivedProduct returnreceivedproduct)
{ returnReceivedProduct.Received = false;
returnReceivedProduct.Receiveddate = null;
}
}
}

By the way, I want thank you for provide the sort of assistance you provide here. It is appreciated by those of us in a pinch.
[Reply][Quote]
Ryan Farley
Posts: 2265
slxdeveloper.com Site Administrator
Top 10 forum poster: 2265 posts
 
Re: Which Usings to Use?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 02 Sep 08 5:19 PM
Your problem comes down to case-sensitivity. The method signature is as follows:

public static void OnCreateStep1( IReturnReceivedProduct returnreceivedproduct)


You're getting a reference to the current ReturnReceivedProduct entity that is being created with the variable named "returnreceivedproduct" (notice all lower case). However, in your code you're referring to it as "returnReceivedProduct" (notice this is not all lower case).

Change your code to use the variable name as passed in and all should work fine.
[Reply][Quote]
Dan Carvin
Posts: 227
 
Re: Which Usings to Use?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 03 Sep 08 9:08 AM
My guess is that everyone who goes from case insensitive languages to case sensitve languages goes through a period of banging their head against the wall over case issues.

Thanks again.
[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): 2/23/2025 11:13:07 PM