Community
Showing results for 
Search instead for 
Do you mean 
Reply

Correct way to update an active record

New Member
Posts: 1
Country: United_Kingdom

Correct way to update an active record

[ Edited ]

We are currently having a few issues programmatically updating the current record that a user has opened up. We are taking the following basic sequence of actions

 

  1. User enters data into a field (and might not click off this field to save the change)
  2. User clicks a button on the record to trigger our behaviour
  3. We read the data from our custom field, pass this data into a 3rd party system, and then try to write the fields back

 

We are finding that Sage does not always save the updated data correctly. We find when going into a record for the first time the values are not saved. What we sometimes see is that all the data flashes onto the record and then disappears, as if the values are written, and then ovewritten again with blank values. We are using the basic code listed at the end of this post. Can anyone point me in the right direction?

 

Thanks,

 

Darren

 

----

 

 

Act.Framework.Opportunities.Opportunity opportunity = this.App.ApplicationState.CurrentOpportunity;

Act.UI.OpportunityView.OpportunityDetailView view = this.App.ActiveControl as Act.UI.OpportunityView.OpportunityDetailView;

 

view.Save(); //Persist any active changes.

 

//Retrieve a value

Act.Framework.MutableEntities.MutableEntityFieldDescriptor getField =

       this.App.ActFramework.Opportunities.GetMutableEntityFieldDescriptor("MyGetColumnName", true);

 

object value = getField.GetValue(opportunity);

 

//Lookup based on this value

 

object newValue;

 

Act.Framework.MutableEntities.MutableEntityFieldDescriptor setField =

       this.App.ActFramework.Opportunities.GetMutableEntityFieldDescriptor("MySetColumnName", true);

 

setField.SetValue(opportunity, newValueConverted);

//OR

opportunity.OpportunityFields[setField.Name, true] = newValue;

 

//Tried various things to persist including

 

opportunity.update();

view.save();

this.App.ApplicationState.CurrentOpportunities.RefreshData();