web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

want to show infolog and capture info in exception

(0) ShareShare
ReportReport
Posted on by 439

Hi All,

I have a batch for importing and posting packing slip for  PO and sometimes while doing so we are getting some set up error   while doing  packing slip like fiscal calendar not defined etc...

so I need to capture the error in  exception log and  same time need to show the error as it is while running the batch job manually 

 private str getErrorStr()
 {
   SysInfologEnumerator enumerator;
   SysInfologMessageStruct msgStruct;
   Exception exception;
   str error;
   enumerator = SysInfologEnumerator::newData(infolog.cut());
   while (enumerator.moveNext())
   {
     msgStruct = new SysInfologMessageStruct(enumerator.currentMessage());
     exception = enumerator.currentException();
      error = msgStruct.message();
      this.method2(error);
   }
   return error;
 }

and 

private void method2(String255 _message)
{
    if(!exceptionID)
    {
    this.CreateExceptionRecord(_message);

    }
    else
    {
    this.createExceptionLines(_message, IntegrationExceptionLog.ExceptionId);

    }
}

and in the main logic class where i am doing packing slip i am calling the below code 

          try
            {
                this.PartialPOPartialPacking(purchTablePartner);
            }
            catch(Exception::Error)
            {
                info("@SON2022");
                this.getErrorStr();
            }

the problem is when i capture the exception by SysInfologMessageStruct and insert  in my exception table 

then the normal PO related info and above custom infolog  defined prior to my logic does not work like 

info(strfmt("PO has been confrimed %1",purchTablePartner.PurchId));

Any help will be appreciated not sure it is normal feature.

so here I need to show infolog as it is in standard  and capture exception in my exception table

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    237,801 Most Valuable Professional on at

    The messages aren't shown in Infolog anymore because your code removes them. If you want to keep them, use infolog.copy() instead of infolog.cut().

  • rohit1900 Profile Picture
    439 on at

    Thanks for the help,

    Now the info are coming as required but there is a problem 

    as for very record i need to break the info in the exception table

     private str getErrorStr()
     {
       SysInfologEnumerator enumerator;
       SysInfologMessageStruct msgStruct;
       Exception exception;
       str error;
         str message;
         int i;
        // i = conFind(infolog, strFmt("@SON2166",invoiceNumberSummary)));  
       enumerator = SysInfologEnumerator::newData(infolog.copy(1,infolog.num()));
       while (enumerator.moveNext())
       {
         msgStruct = new SysInfologMessageStruct(enumerator.currentMessage());
         exception = enumerator.currentException();
          error = msgStruct.message();
          this.method2(error);
       }
         
     }

    say i am processing 2 PO's  and  both gives error and  in the infolog message of the front end.

    but when i see the exception id  it created 2 separate exception id's for 2 PO's but  in the 2nd PO it consists of all the infolog message of 1st PO and 2nd PO , i think i need to break the message infolog my the occurrence of one label like 

     i = conFind(infolog, strFmt("@SON2166",invoiceNumberSummary)));  

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans