Hello,
We have an API that is inserting data into two fields when an Opportunity record is created. Right now the insert happens after record creation while the user is viewing the record. If the user enters any changes and saves, they receive an error since the record was updated via the API. Has anyone faced a similar issue? Is there a way to avoid the error with an automatic screen or field refresh for those two fields? Or a way to pass those fields into the save that is triggered from the user?
Thanks!
Page 1 / 1
Hi
Could you please check the scenario with the code sample below?
I'm not sure if it will work, but you can give it a try.
protected void CROpportunity_FieldDefaulting(PXCache sender, PXFieldDefaultingEventArgs e)
{
var row = (CROpportunity)e.Row;
if (row == null) return;
if (e.FieldName == typeof(CROpportunity.customField1).Name)
{
e.NewValue = row.CustomAPIValue1; // Value set by API
e.Cancel = true;
}
else if (e.FieldName == typeof(CROpportunity.customField2).Name)
{
e.NewValue = row.CustomAPIValue2; // Value set by API
e.Cancel = true;
}
}
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.