OnDemand NAS Codeunits Scheduling
With a little modification of standard NAV “Scheduling Report Page”, is possible to schedule also codeunits !
You don’t need IT department to schedule you applications handled by codeunits (ex: interfaces, intercompany entries, copy company functions etc.), user can schedule codeunits in his NAS session without use of Process Queue management console. Some standard codeunits have HideDialog functions defined, you can use these functions to bypass client input parameters (es: confirm messages etc.), you are in NOT GUIALLOWED mode with NAS.
Examples of utilizations:
- we use OnDemand schedule to launch OnDemand Web Services synchronizations and multicompanies data deployments, we won’t use reports to do this, and we need to handle transactions with great rollback by design (codeunits).
Example
OnDemand schedule of codeunit “99000853 Calc. Low-level code”, that require user input confirmation (Confirm)
Modifications:
Codeunit 99000853 Calc. Low-level code
OnRun()
// Set Hidedialogs TRUE for NAS execution (NAV Service and NAS for user sessions)
IF NOT GUIALLOWED THEN
SetHideDialogs(TRUE);
SetHideDialogs(NewHideDialogs : Boolean)
HideDialogs := NewHideDialogs;
//Standard HideDialogs Function
Custom Page 50001 “Schedule a Codeunit” (new page from “Schedule a Report” Page 682)
Triggers and functions
OnOpenPage()
IF NOT FINDFIRST THEN BEGIN
INIT;
ReportEditable := TRUE;
OutPutEditable := TRUE;
Status := Status::”On Hold”;
VALIDATE(“Object Type to Run”,”Object Type to Run”::Codeunit);
INSERT(TRUE);
END ;
Object ID to Run – OnLookup(VAR Text : Text) : Boolean // Show Codeunits List
IF LookupObjectID(NewObjectID) THEN BEGIN
Text := FORMAT(NewObjectID);
EXIT(TRUE);
END;
EXIT(FALSE);
ScheduleACodeunit(CodeunitId : Integer;RequestPageXml : Text) : Boolean
ScheduleACodeunit.SetParameters(CodeunitId,RequestPageXml);
EXIT(ScheduleACodeunit.RUNMODAL = ACTION::OK);
SetParameters(ReportId : Integer;RequestPageXml : Text)
INIT;
Status := Status::”On Hold”;
VALIDATE(“Object Type to Run”,”Object Type to Run”::Codeunit);
VALIDATE(“Object ID to Run”,ReportId);
INSERT(TRUE);
Example
OnDemand Schedule for codeunit 99000853 “Low Level Code Calculation”
- Select codeunit from list
After Selection
- Validate Codeunit
-
Insert Scheduling Timing
Check in Process Queue entries
- You can find your OnDemand Schedule
Check NAS Log
- Completed !
Download Txt Page from here: Page_50001
You are Welcome !