Showing results for 
Search instead for 
Do you mean 
Community Home Request Access Read Blogs Share Your Ideas Search Community View My Settings
Reply
Tuned Listener
Posts: 67
Registered: ‎11-29-2011

Reload object

Hi,

 

I have a Contact object, after some modification on the object properties, I want the object to be reloaded to its initial state which is the same as the values stored in the database. How could I discard the changes to the properties and reload the object?

 

Thanks a lot!

Nickel Contributor
Posts: 57
Registered: ‎03-18-2010

Re: Reload object

You can try this to remove your contact object from cache :

 

Sage.Platform.EntityFactory.Evict(object.GetType(), object.Id);

 

and then reload it with:

 

Sage.Platform.EntityFactory.GetById(object.GetType(), object.Id);

 

Hope this helps...

Libert Damien
Highlighted
Tuned Listener
Posts: 67
Registered: ‎11-29-2011

Re: Reload object

It doesn't work.

 

I tried above, but after reload, the modify date is still not changed. However, when I query the database outside SalesLogix, I can see the valud there already updated.

Bronze Super Contributor
Posts: 236
Registered: ‎03-30-2009

Re: Reload object

Try the typed version instead.  Note that this assumes that the variable 'a' contains an Account:

 

   Sage.Platform.EntityFactory.Evict<Sage.Entity.Interfaces.IAccount>(a.Id);

 

After doing this, I typically re-direct back to whatever page I was on in order to pick up the new data.

Mike LaSpina
Professional Services Consultant

Sage
8800 N Gainey Center Dr Ste 200
Scottsdale AZ 85258
Tel: 480-383-5344
Cell: 480-321-6637
Fax: 480-556-4090
mike.laspina@sage.com

Your Business in Mind.
Bronze Super Contributor
Posts: 152
Registered: ‎02-01-2011

Re: Reload object

This redirect code works in a code snippet:

 

using System.Web;
HttpContext.Current.Response.Redirect(HttpContext.Current.Request.Url.ToString());

Andy Freeman
TrellisPoint, LLC