Skip to main content
Solved

How to pass ext RefNbr in issue to Journal Ext Ref


Forum|alt.badge.img

 

Best answer by vardan22

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
}

 

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

4 replies

Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 44 replies
  • September 23, 2023

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


vardan22
Jr Varsity III
Forum|alt.badge.img+1
  • Jr Varsity III
  • 44 replies
  • Answer
  • September 23, 2023

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
}

 


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 44 replies
  • September 24, 2023
vardan22 wrote:

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


Forum|alt.badge.img
  • Author
  • Jr Varsity II
  • 44 replies
  • September 24, 2023
kevinheng21 wrote:
vardan22 wrote:

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


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