5/5/2026 7:44:34 AM
|
| |
| 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!
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.
|
|
|
|
Update CurrentEntity
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 |
|
|
|
Re: Update CurrentEntity
Posted: 04 Jan 10 3:24 PM
|
IOpportunityJob newOppJob = this.BindingSource.Current as IOpportunityJob ; newOppJob.Save(); |
|
|
|
Re: Update CurrentEntity
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. |
|
|
|
Re: Update CurrentEntity
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. |
|
|
|
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!
|
|
|
|
|
|
|
|