Skip to main content
Answer

Auto refresh screen after record creation

  • October 28, 2024
  • 2 replies
  • 111 views

temberson
Freshman II

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!

Best answer by jinin

Hi @temberson ,

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;
}
}

 

2 replies

jinin
Pro I
Forum|alt.badge.img+11
  • Pro I
  • Answer
  • October 29, 2024

Hi @temberson ,

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;
}
}

 


Forum|alt.badge.img
  • Freshman II
  • July 21, 2025

@temberson I have the same problem! Did you find any solution?