Skip to main content
Solved

Auto refresh screen after record creation

  • October 28, 2024
  • 1 reply
  • 45 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;
    }
}

 

View original
Did this topic help you find an answer to your question?

1 reply

jinin
Pro I
Forum|alt.badge.img+11
  • Pro I
  • 698 replies
  • 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;
    }
}

 


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings