Job journal posting error

Question Status

Verified
Bifa asked a question on 17 May 2018 1:56 AM

Dear Fellows,

My company has been using Microsoft dynamics NAV 2016 for the last two years. A couple of days ago one of the end users want to post entry in the JOB Journal but an error message which reads:

Microsoft Dynamics NAV
---------------------------

The object has been run. Use the function CLEAR(Report).
---------------------------
OK
---------------------------

keeps poping up and the posting process fails, what could be the cause of this error message. I really need your help ASAP.

for more info, here is the screen shot of the message 

Reply
Suggested Answer
Olister Rumao responded on 17 May 2018 4:31 AM

Hi Bifa,

Add the CLEAR(ReportName) code wherever the Job is called. Or close the page and repeat the posting process.

Reply
Bifa responded on 17 May 2018 4:53 AM

Thank You Olister for your swift reply,

I've tried the closing the page and repeating the posting process it gives me the same error.

However the first solution you suggested "Add the CLEAR(ReportName) code wherever the Job is called" , how do i add the CLEAR(ReportName) in the job journal, can you give me a detailed explanation on that?

Reply
Suggested Answer
Stefano Demiliani responded on 17 May 2018 5:20 AM

It seems so strange that the Job Journal posting is calling a report variable. Are you able to activate debugger? If so, you can see immediately where the problem is. I suspect you have here a custom implementation, maybe that opens a report after posting?

Reply
Bifa responded on 17 May 2018 5:41 AM

Hello Stefano,

When i debug it here is what i found the error message pops up when it reaches the yellow color highlighted line of code ,  any idea what that is and any suggestion on how to fix it, because i'm not that familiar with C/AL codes

Reply
Suggested Answer
Stefano Demiliani responded on 17 May 2018 6:11 AM

RUNMODAL inside a loop? This seems a wrong code.

You can place CLEAR(UpdateJobItemCost) just after the REPEAT line but this code seems wrong to me.

A RUNMODAL waits for user input and inside a loop it’s very bad because it locks the transaction.

Reply
Bifa responded on 17 May 2018 10:57 AM

Do you think it will cause me some other issues if i comment out the code line in the code unit? what do you think i should do?

Reply
Verified Answer
Stefano Demiliani responded on 17 May 2018 11:10 AM

To solve your issue, the code must be the following:

LOCAL UpdateJobItemCost()

IF JobsSetup.FIND THEN
IF JobsSetup."Automatic Update Job Item Cost" THEN BEGIN
IF TempJobToAdjustBuf.FINDSET THEN
REPEAT
Job.SETRANGE("No.",TempJobToAdjustBuf."No.");
CLEAR(UpdateJobItemCost);       //<-- ADD THIS LINE!!
UpdateJobItemCost.SETTABLEVIEW(Job);
UpdateJobItemCost.USEREQUESTPAGE := FALSE;
UpdateJobItemCost.SetProperties(TRUE);
UpdateJobItemCost.RUNMODAL;
UNTIL TempJobToAdjustBuf.NEXT = 0;
END;

Reply
Olister Rumao responded on 17 May 2018 11:11 AM

Hi Bifa,

On the Post Action check what Customisation is done. Do not comment any code but if Report object is called then use CLEAR(ReportObject).

Reply
Suggested Answer
Chris D'silva responded on 17 May 2018 10:53 PM

Hi,

Use session debugging, it will direct you to th error

Reply
Bifa responded on 18 May 2018 2:08 AM

Hello Stefano,

First i would like to thank every one who participated to give solution to the issue i posted. i really appreciate it.

especially Thank You Stefano, I added the code you suggested the entry posted with out any problem. the solution works like charm. I have one question though , does the change in the code could affect any other item cost adjustment entries or cause and issue on other item related transaction, what do you think?,

And also for my understanding on the issues  can you give me a brief explanation why the issue was happening and what the code you added does? thank you again  for your support.

Reply
Verified Answer
Stefano Demiliani responded on 18 May 2018 2:29 AM

No, tested and it works. This issues was fixed in the following releases.

The line of code simply re-initialize the variable used for posting for passing the new filters on every iteration.

Reply
Verified Answer
Stefano Demiliani responded on 17 May 2018 11:10 AM

To solve your issue, the code must be the following:

LOCAL UpdateJobItemCost()

IF JobsSetup.FIND THEN
IF JobsSetup."Automatic Update Job Item Cost" THEN BEGIN
IF TempJobToAdjustBuf.FINDSET THEN
REPEAT
Job.SETRANGE("No.",TempJobToAdjustBuf."No.");
CLEAR(UpdateJobItemCost);       //<-- ADD THIS LINE!!
UpdateJobItemCost.SETTABLEVIEW(Job);
UpdateJobItemCost.USEREQUESTPAGE := FALSE;
UpdateJobItemCost.SetProperties(TRUE);
UpdateJobItemCost.RUNMODAL;
UNTIL TempJobToAdjustBuf.NEXT = 0;
END;

Reply
Verified Answer
Stefano Demiliani responded on 18 May 2018 2:29 AM

No, tested and it works. This issues was fixed in the following releases.

The line of code simply re-initialize the variable used for posting for passing the new filters on every iteration.

Reply
Suggested Answer
Olister Rumao responded on 17 May 2018 4:31 AM

Hi Bifa,

Add the CLEAR(ReportName) code wherever the Job is called. Or close the page and repeat the posting process.

Reply
Suggested Answer
Stefano Demiliani responded on 17 May 2018 5:20 AM

It seems so strange that the Job Journal posting is calling a report variable. Are you able to activate debugger? If so, you can see immediately where the problem is. I suspect you have here a custom implementation, maybe that opens a report after posting?

Reply
Suggested Answer
Stefano Demiliani responded on 17 May 2018 6:11 AM

RUNMODAL inside a loop? This seems a wrong code.

You can place CLEAR(UpdateJobItemCost) just after the REPEAT line but this code seems wrong to me.

A RUNMODAL waits for user input and inside a loop it’s very bad because it locks the transaction.

Reply
Suggested Answer
Chris D'silva responded on 17 May 2018 10:53 PM

Hi,

Use session debugging, it will direct you to th error

Reply