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

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Dot Net Variables in NAS

(0) ShareShare
ReportReport
Posted on by 1,144

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

*This post is locked for comments

I have the same question (0)
  • subrata.bauri Profile Picture
    1,144 on at
    RE: A call to Microsoft.Dynamics.Nav.Integration.Office.Word.WordHelper.CallSaveAsFormat failed Parameter name: document

    deleted

  • subrata.bauri Profile Picture
    1,144 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
    1,144 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.

  • Suggested answer
    Guillem Padilla Profile Picture
    427 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
    1,144 on at
    RE: Dot Net Variables in NAS

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

  • subrata.bauri Profile Picture
    1,144 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
    1,144 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);
  • Sergisoft Profile Picture
    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.

  • Suggested answer
    AlexeiPavlov1974 Profile Picture
    5 on at
    RE: Dot Net Variables in NAS

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

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
Alexander Ermakov Profile Picture

Alexander Ermakov 2

#2
SC666 Profile Picture

SC666 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans