Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Friday, June 6, 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: Possible to overwrite method Delete globally? Or create new 'global' method?
Tim Zech
Posts: 40
 
Possible to overwrite method Delete globally? Or create new 'global' method?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 13 Nov 13 9:46 AM

Hi there, I'm curious if it's possible to overwrite the 'Delete' method. Or maybe to define own 'global' methods like Save() and Delete().

Background:
I'm supposed to rather flag something as 'deleted' instead of really deleting something. Since it needs a lot of patience to implement a property called 'Deleted' and a method called 'DeleteRestore' on every single entity and it's also hard to maintain if something somewhere changes, I'd thought of implementing the property only on the entities necessary and then check for it's existence in the 'DeleteRestore' method. If it exists, it gets flipped; if not, it calls Delete() on the entity.

Currently I'm using an external method like:

ExternalLibrary.GenericMethods.DeleteRestore(object entity)
{
Type entityType = entity.GetType();
bool? deleted;

try
{
PropertyInfo pi = entityType.GetProperty("Deleted");
deleted = ((bool?)pi.GetValue(entity, null)) ?? false);
pi.SetValue(entity, !deleted, null);

MethodInfo mi = entityType.GetMethod("Save");
mi.Invoke(entity, new object[0]);
}
catch { }
}


to achieve this. But I don't like it that much. I'd rather like to use a 'global' method, so I can call something like

ticket.DeleteRestore();


instead of

ExternalAssembly.GenericMethods.DeleteRestore(ticket);


 

[Reply][Quote]
Tim Zech
Posts: 40
 
Re: Possible to overwrite method Delete globally? Or create new 'global' method?Your last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 14 Nov 13 1:19 PM

Someone on saleslogix.com told me to look up the code templates. I did this and changed the following there:


<#	OrmEntityProperty deleted = entity.GetPropertyByPropertyName("Deleted"); #>
<# if (deleted != null) #>
<# { #>
public override void Delete()
{
// Put the magic here
}

public override void Restore()
{
// Put some other magic here
}
<# } #>
<# else #>
<# { #>
public override void Delete()
{
// The current magic happens here
}
<# } #>

This works well and looks nice, but I realized this is a way bigger task than expected. I think, I'll stick with the current solution for now and might get back to this later.

[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): 6/6/2025 10:09:45 AM