SBX - Search With Button

SBX - Forum Post Title

Dialog window in InitProgressWindow method in Sales-Post Codeunit 80

Dynamics 365 Business Central Forum

Wiechardt Brummer asked a question on 10 Oct 2018 5:56 AM

Question Status

Suggested Answer

Hi there,

I have an extension that's posting sales documents through a scheduled task and I am running into a problem with the Sales-Post codeunit with regards to the Window/Dialog.

The InitProgressWindow contains the code shown below - how do I avoid the code in red raising an error when the Client Type = SOAP, API or NAS, i.e. in instances when the code is executed from a client where the Dialog is not supported without changing this code?

IF PurchHeader.Invoice THEN
Window.OPEN(
'#1#################################\\' +
PostingLinesMsg +
PostingPurchasesAndVATMsg +
PostingVendorsMsg +
PostingBalAccountMsg)
ELSE
Window.OPEN(
'#1############################\\' +
PostingLines2Msg);

Thanks,

Wiechardt

Reply
Suggested Answer

I've not an environment here to check at the moment but you cannot avoid the dialog if this is the Microsoft's code. Normally you should place IF GUIALLOWED THEN before the OPEN dialog method if you want to use this function in WS or job queue.

Have you checked if Microsoft do that before calling InitProgressWindow? Something like:

IF GUIALLOWED THEN

  InitProgressWindow

ELSE

...

Reply
Wiechardt Brummer responded on 11 Oct 2018 4:20 AM

Hi Stefano,

Thanks for your response.  

The method/code calling the InitProgressWindow does not have a IF GUIALLOWED check but the good news is, for some reason, the document does indeed get posted even with this code in place.  I guess Microsoft built in some underlying logic to suppress dialogs when the code is executed in the context of NAS/SOAP/API.

Regards,

Wiechardt

Reply
Suggested Answer

I've not an environment here to check at the moment but you cannot avoid the dialog if this is the Microsoft's code. Normally you should place IF GUIALLOWED THEN before the OPEN dialog method if you want to use this function in WS or job queue.

Have you checked if Microsoft do that before calling InitProgressWindow? Something like:

IF GUIALLOWED THEN

  InitProgressWindow

ELSE

...

Reply

SBX - Two Col Forum

SBX - Migrated JS