AutoJobWIPValueAndRecognition() JobSetup.GET; //Check the number series IF GUIALLOWED THEN BEGIN JobSetup.TESTFIELD(KBAutoJobWIPNos); JobSetup.TESTFIELD(KBAutoJobRecogNos); JobSetup.TESTFIELD(KBSaveResultsToFolder); END ELSE IF (JobSetup.KBAutoJobWIPNos='') OR (JobSetup.KBAutoJobRecogNos='') OR (JobSetup.KBSaveResultsToFolder='') THEN EXIT; //Generate two new numbers NoSeriesMgt.InitSeries(JobSetup.KBAutoJobWIPNos,'',WORKDATE,WIPNo,Buffer); NoSeriesMgt.InitSeries(JobSetup.KBAutoJobRecogNos,'',WORKDATE,RecogNo,Buffer); //Clear the variables CLEAR(JobRec); CLEAR(JobLedEntryRec); CLEAR(TempFolder); CLEAR(ZipFolder); CLEAR(WIPFile); CLEAR(RecogFile); CLEAR(CalculateJobWIPValue); CLEAR(PostJobWIPValuetoGL); CLEAR(CalculateJobRecognition); CLEAR(PostJobRecognitiontoGL); CLEAR(Subject); CLEAR(Body); //Get the system's temp folder TempFolder := KBGenFuncCU.GetTempFolder; WIPFile := TempFolder + '\' + WIPNo + '.html'; RecogFile := TempFolder + '\' + RecogNo + '.html'; JobRec.RESET; JobLedEntryRec.RESET; //Calculate WIP Value CalculateJobWIPValue.SETTABLEVIEW(JobRec); CalculateJobWIPValue.SETTABLEVIEW(JobLedEntryRec); CalculateJobWIPValue.USEREQUESTFORM(FALSE); CalculateJobWIPValue.RUN; //Post WIP Value to G/L PostJobWIPValuetoGL.InitializeRequest(0, '', WORKDATE, WIPNo); PostJobWIPValuetoGL.SETTABLEVIEW(JobRec); PostJobWIPValuetoGL.SETTABLEVIEW(JobLedEntryRec); PostJobWIPValuetoGL.USEREQUESTFORM(FALSE); PostJobWIPValuetoGL.SAVEASHTML(WIPFile); //Calculate recognition CalculateJobRecognition.SETTABLEVIEW(JobRec); CalculateJobRecognition.SETTABLEVIEW(JobLedEntryRec); CalculateJobRecognition.USEREQUESTFORM(FALSE); CalculateJobRecognition.RUN; //Post recognistion to G/L PostJobRecognitiontoGL.InitializeRequest(0, '', WORKDATE, RecogNo); PostJobRecognitiontoGL.SETTABLEVIEW(JobRec); PostJobRecognitiontoGL.SETTABLEVIEW(JobLedEntryRec); PostJobRecognitiontoGL.USEREQUESTFORM(FALSE); PostJobRecognitiontoGL.SAVEASHTML(RecogFile); //Save the result set to file IF KBGenFuncCU.StrEndsWith(JobSetup.KBSaveResultsToFolder, '\', FALSE) THEN ZipFolder := JobSetup.KBSaveResultsToFolder ELSE ZipFolder := JobSetup.KBSaveResultsToFolder + '\'; ZipFile := ZipFolder + COMPANYNAME + '_' + WIPNo + '_' + RecogNo + '.zip'; KBZipCU.ZipFileName_Set(ZipFile); IF KBZipCU.AddFileToZipQueue(WIPFile) THEN; IF KBZipCU.AddFileToZipQueue(RecogFile) THEN; IF KBZipCU.ProcessZipQueue THEN; //Send notification email IF JobSetup.KBAutoJobWIPRecogNotify <> '' THEN BEGIN InitCrLf; Subject := 'Job WIP & Recognition - ' + COMPANYNAME + ' - ' + FORMAT(WORKDATE) + ' ' + FORMAT(TIME); Body += STRSUBSTNO(Text0001, COMPANYNAME) + CrLf + CrLf; Body += STRSUBSTNO(Text0002, WIPNo) + CrLf; Body += STRSUBSTNO(Text0003, RecogNo); IF KBMailCU.SendMessage(JobSetup.KBAutoJobWIPRecogNotify,'',Subject,Body,'') THEN; END; //Delete the temp files IF EXISTS(WIPFile) THEN KBGenFuncCU.DeleteFile(WIPFile); IF EXISTS(RecogFile) THEN KBGenFuncCU.DeleteFile(RecogFile);
InitCrLf() CrLf[1] := 10; CrLf[2] := 13; Cr[1] := 10;
Answers
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
Independent Consultant/Developer
blog: https://dynamicsuser.net/nav/b/ara3n
Create 2 batchfiles to start and stop the service (or only start in case you don't use singleinstance codeunits. at the end of all the Navision commands you can put a COMMIT and then an error to let the NAS crash (instead of just stopping it).
In the scheduler you only need a "NET START NASSERVICE" to start the service.
PS I hope your license is enable to use the NAS, otherwise you can never use the NAS.
No PM,please use the forum. || May the <SOLVED>-attribute be in your title!
MVP - Dynamics NAV
My BLOG
NAVERTICA a.s.
The following instances all use the domain admin's credentials:
1. The .NET app, which starts and stops the NAS service.
2. NAS.
3. The Windows Login setup in Navision.
The .NET app uses the ServiceManager class to start and stop NAS.
Our license does include NAS, because I'm already using it to run/automate other processes.
It is just this one which won't play along.
The essence of the problem is that I can run the codeunit from the client, logged in as the domain admin, but get a permissions error when NAS runs it, logged in as the domain admin.
Thanks kine, I will try to get hold of the hotfixes.
Regards,
Charl
All four the reports mentioned in my initial post updates the Job Ledger Entry table. Craig suggested that I add a function to my calling codeunit, which will accept an argument of type Job Ledger Entry as ByRef. The only thing this function then does, is to run the MODIFY function on the record. The permissions on the CodeUnit was then set as : TableData Job Ledger Entry=rimd
All four reports were modified to call my codeunit's update function, instead of the record's MODIFY function, passing the record which needs to be modified as an argument.
This worked like a charm, and I can now run the codeunit from NAS without any errors.
Regards,
Charl