Home | Forums | Contact | Search | Syndication  
 
 [login] [create account]   Tuesday, July 1, 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: Update CurrentEntity
Ronnie Martin
Posts: 26
 
Update CurrentEntityYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 04 Jan 10 11:32 AM
Is there a way to update the CurrentEntity for a form?

I tried the following.

//IOpportunityJob newOppJob = EntityFactory.Create<IOpportunityJob>();
//newOppJob.Save();
//CurrentEntity = newOppJob;
//Refresh();

But I get the Error "Property or indexer 'SmartParts_OpportunityJob_OppJobForm.CurrentEntity' cannot be assigned to -- it is read only "

When I try

//IOpportunityJob newOppJob = EntityFactory.Create<IOpportunityJob>();
//newOppJob.Save();
//BindingSource.Current = newOppJob;
//Refresh();

I get the Error "Object reference not set to an instance of an object."

Any advice?

Thanks,
Ronnie
[Reply][Quote]
Kris Halsrud
Posts: 88
 
Re: Update CurrentEntityYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 04 Jan 10 3:24 PM
IOpportunityJob newOppJob = this.BindingSource.Current as IOpportunityJob ;
newOppJob.Save();
[Reply][Quote]
Ronnie Martin
Posts: 26
 
Re: Update CurrentEntityYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 04 Jan 10 3:46 PM
Thanks. That works for part of what I am trying to do. I want to click a link button that will create a new record and show it.

The problems comes in when I click on Save at the top of the screen. It will save the "CurrentEntity" and that seems to be different from what i am seeing, so it always creates a new record. I was hoping I could update CurrentEntity to be the record I am looking at, so when the user clicks save it doesn't create an additional record, but saves the changes.
[Reply][Quote]
Alec Denholm
Posts: 34
 
Re: Update CurrentEntityYour last visit to this thread was on 1/1/1970 12:00:00 AM
Posted: 05 Jan 10 3:26 AM
You've not told the EntityFactory precisely what it is you want to Create. Try stating the object type explicitly:

IWidget mywidget = (IWidget)EntityFactory.Create< IWidget>();
mywidget.Description = "New Widget";
mywidget.GenericProperty = someDefaultValue;
mywidget.Save();

Then you could set BindingSource.Current to the new Entity (assuming a bound form).

EDIT: I should have explained this also. This code:

IOpportunityJob newOppJob = this.BindingSource.Current as IOpportunityJob ;
newOppJob.Save();

...does not set the BindingSource.Current to your new entity. Rather it sets your new Entity variable to be the current BindingSource.Current, which presumably has not been changed to be your new entity yet. The flow should go something like:

Create new Widget.
Set the BindingSource.Current = newWidget. Previously you'd set newWidget = BindingSource.Current, which is probably not what you wanted to do, and would explain your issue.
New Widget is now in context so all form buttons will effect it rather than the old Widget.
[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): 7/1/2025 7:56:44 AM