Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV forum
Suggested answer

Dot Net Variables in NAS

Posted on by 1,112

Dear Sir,

I'm facing a problem with the DotNet variable in NAS Environment (NAV 2016). I have declared all the DotNet variables in a Codeunit to convert the WORDLAYOUT of a Report output into a HTML file. After that the Codeunit send the same HTML file in a email body.

It's working fine when I execute the Codeunit manually. It creates WORD file, converts it into HTML and then send the same HTML in the body of the email. During manual execution I have to declare all the DotNet variable as RunOnClient YES.

And in NAS Environment I have declared the same DotNet variables as RunOnClient No .

The piece of the Custom Code is as follows....

WordApplication :=WordApplication.ApplicationClass;
WordDocument :=WordHelper.CallOpen(WordApplication,FileName,FALSE,TRUE);
FileName2 := TEMPORARYPATH + DELCHR(FORMAT(CURRENTDATETIME),'=','\/:*?"<>| ');
WordHelper.CallSaveAsFormat(WordDocument,FileName2,WordSaveFormat.wdFormatHTML);


The NAS has found null value in the first parameter of "CallSaveAsFormat" function and hence it gives the following error message.

Microsoft Dynamics NAV

A call to Microsoft.Dynamics.Nav.Integration.Office.Word.WordHelper.CallSaveAsFormat failed with this message: Value cannot be null.
Parameter name: document
OK


I can't find the reason why it is doing so in NAS. If you have any idea about the same please reply.
Thank you,

Subrata Bauri

  • Suggested answer
    RE: Dot Net Variables in NAS

    Amazing! It works. But why? And how did you find this?

  • Sergisoft Profile Picture
    Sergisoft 20 on at
    RE: Dot Net Variables in NAS

    I know you won't believe it... but I had exactly the same issue and I fixed creating a folder.

    Just create a new "Desktop" directory inside of "C:\Windows\SysWOW64\config\systemprofile\"

    I was about to get crazy.

  • subrata.bauri Profile Picture
    subrata.bauri 1,112 on at
    RE: Dot Net Variables in NAS

    Will NAS be able to execute the following C/AL code on NAV 2016 ?

    WordApplication :=WordApplication.ApplicationClass;
    WordDocument :=WordHelper.CallOpen(WordApplication,FileName,FALSE,FALSE);
  • subrata.bauri Profile Picture
    subrata.bauri 1,112 on at
    RE: Dot Net Variables in NAS

    I have found the same error message....

    Microsoft Dynamics NAV
    
    A call to Microsoft.Dynamics.Nav.Integration.Office.Word.WordHelper.CallSaveAsFormat failed with this message: Value cannot be null.
    Parameter name: document
    OK


    When I run the Codeunit manually after declaring all the DotNet variable as RunOnClient No.

  • subrata.bauri Profile Picture
    subrata.bauri 1,112 on at
    RE: Dot Net Variables in NAS

    I'm sitting in the server pc & it has word installed.

  • Suggested answer
    Guillem Padilla Profile Picture
    Guillem Padilla 425 on at
    RE: A call to Microsoft.Dynamics.Nav.Integration.Office.Word.WordHelper.CallSaveAsFormat failed Parameter name: document

    Hi,

    Is any of these functions trying to open a window or make any user interaction?

    If it is, you should use GUIALLOWED function to avoid user interactions in job queue

    Are you executing it manually in the same machine? Maybe Server side needs to have word installed...

  • subrata.bauri Profile Picture
    subrata.bauri 1,112 on at
    RE: A call to Microsoft.Dynamics.Nav.Integration.Office.Word.WordHelper.CallSaveAsFormat failed Parameter name: document

    The value of the first parameter of the function "CallSaveAsFormat" is found null, that's why it's showing error message.

  • subrata.bauri Profile Picture
    subrata.bauri 1,112 on at
    RE: A call to Microsoft.Dynamics.Nav.Integration.Office.Word.WordHelper.CallSaveAsFormat failed Parameter name: document

    The above mentioned code working fine when I execute it manually after declaring dot net variables as RUNONCLIENT.

    But the same thing is not happening when executing thru NAS after declaring dot net variables As RUN on server side.

  • subrata.bauri Profile Picture
    subrata.bauri 1,112 on at
    RE: A call to Microsoft.Dynamics.Nav.Integration.Office.Word.WordHelper.CallSaveAsFormat failed Parameter name: document

    deleted

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

Anton Venter – Community Spotlight

Kudos to our October Community Star of the month!

Announcing Our 2024 Season 2 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Dynamics 365 Community Newsletter - September 2024

Check out the latest community news

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,554 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 228,588 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans