Solved

How to pass ext RefNbr in issue to Journal Ext Ref

  • 22 September 2023
  • 4 replies
  • 48 views

Userlevel 3
Badge

 

icon

Best answer by vardan22 23 September 2023, 12:23

View original

4 replies

Userlevel 4
Badge +1

You just need to override the ReleaseDocProc method specified in the INReleaseProcess graph.

public class INReleaseProcessExt : PXGraphExtension<INReleaseProcess>
{
public static bool IsActive() => true;

#region PXOverride
public delegate void ReleaseDocProcDelegate(JournalEntry je, INRegister doc, bool releaseFromHold = false);
[PXOverride]
public virtual void ReleaseDocProc(JournalEntry je, INRegister doc, bool releaseFromHold, ReleaseDocProcDelegate releaseDocProc)
{
releaseDocProc(je, doc, releaseFromHold);
Batch batch = je.BatchModule.Current;
if (batch != null && doc.DocType == INDocType.Issue)
{
batch.Description = doc.ExtRefNbr;
//for extension fields need to get an extension class and then the fields
je.BatchModule.Update(batch);
je.Save.Press();
}
}
#endregion
}

 

Userlevel 3
Badge

You just need to override the ReleaseDocProc method specified in the INReleaseProcess graph.

public class INReleaseProcessExt : PXGraphExtension<INReleaseProcess>
{
public static bool IsActive() => true;

#region PXOverride
public delegate void ReleaseDocProcDelegate(JournalEntry je, INRegister doc, bool releaseFromHold = false);
[PXOverride]
public virtual void ReleaseDocProc(JournalEntry je, INRegister doc, bool releaseFromHold, ReleaseDocProcDelegate releaseDocProc)
{
releaseDocProc(je, doc, releaseFromHold);
Batch batch = je.BatchModule.Current;
if (batch != null && doc.DocType == INDocType.Issue)
{
batch.Description = doc.ExtRefNbr;
//for extension fields need to get an extension class and then the fields
je.BatchModule.Update(batch);
je.Save.Press();
}
}
#endregion
}

 

I try with your code “description field” has updated but extension fields not update. here is my code

public class INReleaseProcess_Extension : PXGraphExtension<INReleaseProcess>
{
    // Acuminator disable once PX1096 PXOverrideSignatureMismatch [Justification]
  public delegate void ReleaseDocProcDelegate(JournalEntry je, INRegister doc, bool releaseFromHold);
    [PXOverride]
  public void ReleaseDocProc(
  JournalEntry je,
  INRegister doc, bool releaseFromHold,
  INReleaseProcess_Extension.ReleaseDocProcDelegate baseMethod)
    {
        //je.RowInserted.AddHandler<Batch>(((cache, e) =>
        //{
        //    Batch glBatch = e.Row as Batch;
        //    BatchExt batch = PXCache<Batch>.GetExtension<BatchExt>(glBatch);
        //    batch.UsrExternalRefNbr = doc.ExtRefNbr;
        //    //je.BatchModule.Current.GetExtension<BatchExt>().UsrExternalRefNbr = doc.ExtRefNbr;
        //    //je.BatchModule.Current.Description = "test1";
        //}
        //));
        baseMethod(je, doc, releaseFromHold);
        Batch batch = je.BatchModule.Current;
        if (batch != null && doc.DocType == INDocType.Issue)
        {
            //batch.Description = doc.ExtRefNbr;
            BatchExt batchext = PXCache<Batch>.GetExtension<BatchExt>(batch);
            batchext.UsrExternalRefNbr = doc.ExtRefNbr;
            batch.Description = doc.ExtRefNbr.ToString();
            //for extension fields need to get an extension class and then the fields
            je.BatchModule.Update(batch);
            je.Save.Press();
        }
    }
}

I solved it by  je.BatchModule.SetValueExt<BatchExt.usrExternalRefNbr>(batch,doc.ExtRefNbr);

thank you very much

Userlevel 3
Badge

I want to pass ext ref in issue screen to my custom field in journal screen when release action in issue screen.

Userlevel 3
Badge

You just need to override the ReleaseDocProc method specified in the INReleaseProcess graph.

public class INReleaseProcessExt : PXGraphExtension<INReleaseProcess>
{
public static bool IsActive() => true;

#region PXOverride
public delegate void ReleaseDocProcDelegate(JournalEntry je, INRegister doc, bool releaseFromHold = false);
[PXOverride]
public virtual void ReleaseDocProc(JournalEntry je, INRegister doc, bool releaseFromHold, ReleaseDocProcDelegate releaseDocProc)
{
releaseDocProc(je, doc, releaseFromHold);
Batch batch = je.BatchModule.Current;
if (batch != null && doc.DocType == INDocType.Issue)
{
batch.Description = doc.ExtRefNbr;
//for extension fields need to get an extension class and then the fields
je.BatchModule.Update(batch);
je.Save.Press();
}
}
#endregion
}

 

I try with your code “description field” has updated but extension fields not update. here is my code

public class INReleaseProcess_Extension : PXGraphExtension<INReleaseProcess>
{
    // Acuminator disable once PX1096 PXOverrideSignatureMismatch [Justification]
  public delegate void ReleaseDocProcDelegate(JournalEntry je, INRegister doc, bool releaseFromHold);
    [PXOverride]
  public void ReleaseDocProc(
  JournalEntry je,
  INRegister doc, bool releaseFromHold,
  INReleaseProcess_Extension.ReleaseDocProcDelegate baseMethod)
    {
        //je.RowInserted.AddHandler<Batch>(((cache, e) =>
        //{
        //    Batch glBatch = e.Row as Batch;
        //    BatchExt batch = PXCache<Batch>.GetExtension<BatchExt>(glBatch);
        //    batch.UsrExternalRefNbr = doc.ExtRefNbr;
        //    //je.BatchModule.Current.GetExtension<BatchExt>().UsrExternalRefNbr = doc.ExtRefNbr;
        //    //je.BatchModule.Current.Description = "test1";
        //}
        //));
        baseMethod(je, doc, releaseFromHold);
        Batch batch = je.BatchModule.Current;
        if (batch != null && doc.DocType == INDocType.Issue)
        {
            //batch.Description = doc.ExtRefNbr;
            BatchExt batchext = PXCache<Batch>.GetExtension<BatchExt>(batch);
            batchext.UsrExternalRefNbr = doc.ExtRefNbr;
            batch.Description = doc.ExtRefNbr.ToString();
            //for extension fields need to get an extension class and then the fields
            je.BatchModule.Update(batch);
            je.Save.Press();
        }
    }
}

Reply


About Acumatica ERP system
Acumatica Cloud ERP provides the best business management solution for transforming your company to thrive in the new digital economy. Built on a future-proof platform with open architecture for rapid integrations, scalability, and ease of use, Acumatica delivers unparalleled value to small and midmarket organizations. Connected Business. Delivered.
© 2008 — 2024  Acumatica, Inc. All rights reserved