This example reviews how to schedule tests automatically. Create a work center test that runs automatically every morning. For your setup, configure the information to suit your needs.
Ensure you have a source configuration for the required record
- Navigate to Quality Inspector Source Configuration List in Business Central.
- Select New and modify the following fields in the General section:
- Code: WORKCENTER
- Description: Work Center Example
- State: Enabled
- From Table: Work Center
- Modify the fields in the What Information Should be Added to the Test section:
- From Field Name: No.
- To Field Name: Document No.
Now you can use the work center as a record to create your tests.
Create a Quality Inspection Template to use for automated tests
- Navigate to Test Templates in Business Central.
- Select New and modify the following fields in the General section:
- Code: EXAMPLE
- Description: 5S Work Center Example
- Select Add Field(s) To This Template and select Next.
- Modify the following fields:
- Description: Have unnecessary items in your workspace been removed? (Press Enter after inserting.)
- Short name (Field Code): (auto populates with “HAVEUNNECESSARYITEMS”)
- What type of data is it?: A choice from a list
- Select Next.
- Input “YES” on the first line and “NO” on the second line in the Code field.
- Select Finish.
- Select Add Field(s) To This Template and select Next.
- Modify the following fields:
- Description: Are tools, materials, and equipment arranged for a good workflow? (Press Enter after inserting.)
- Short name (Field Code): (auto populates with “RETOOLSMATERIALSANDE”)
- What type of data is it?: A choice from a list
- Select Next.
- Input “YES” on the first line and “NO” on the second line in the Code field.
- Select Finish.
- Select Test Generation Rules.
- Select the Table field, select “Work Center”, and select OK.
Verify the test code and publish the code unit
To use the code example below, you need the following pre-requisite:
- A Quality Inspector Source configuration record for the work center (if you do not have one).
- A Quality Inspection Template with the metrics you would like to collect.
- A Quality Inspection Test Generation Rule that tells the system which Quality Inspection Template you want to use in which circumstances.
Review the test’s code with this example. The codeunit that does the work is described like this:
codeunit 50700 "Example-Create Test Job Queue"
{
Description = 'Example - Create a test with a job queue.';
TableNo = "Job Queue Entry";
trigger OnRun()
var
lrecWorkCenter: record "Work Center";
lcuIWXQICreateTest: Codeunit "IWX QI Create Test";
lrrefCreateTestOnRecordRef: RecordRef;
begin
// Step 1 : find the record you want to create your test with.
// in this example we're using a work center for the intent of a 5S test.
// If you are testing this example or altering it then you would use your own
// logic to find the record you wanted.
// We're using the 'Parameter string' field to define which work center we want.
// For example, if your work center was called 'QUALITY INSPECTION' that you wanted
// to create your 5S test with then in your job queue entry configuration you would put in the
// name of the work center there.
if not lrecWorkCenter.Get(copystr(Rec."Parameter String", 1, maxstrlen(lrecWorkCenter."No."} then
error('This example uses the Parameter String field on the Job Queue Entry card to determine which work center you want to use. Please configure the Parameter String there.');
lrrefCreateTestOnRecordRef.GetTable(lrecWorkCenter);
// Step 2 : create the test. This would require you to have a test generation rule configured.
// 'false' for the second parameter tells the system this test was created manually by hand.
// 'true' for the second parameter tells the system this test was created automatically.
// This can be used to work with the 'show test' configuration option on the Quality Inspector Setup record.
lcuIWXQICreateTest.CreateTest(lrrefCreateTestOnRecordRef, true);
end;
}
Once you have the pre-requisite configuration and have published your codeunit, you can create a Job Queue Entry to schedule a test using that codeunit.
Configure the test schedule and run the test
- Navigate to Job Queue Entries in Business Central.
- Select New.
- Modify the following fields:
- Object Type to Run: Codeunit
- Object ID to Run: 50700 (the codeunit we created)
- Parameter String: 100
- Modify the Recurrence section as needed (e.g., Run on Tuesdays with 7:00:00 AM Starting Time)
- Select Run once (foreground) and select Yes to test.
- Select OK and view the created test.
- Select Set Status to Ready.
- Select Log Entries (if test has run) to view the successful test run.
Video
The following video goes through the process of scheduling automated tests with Quality Inspector.
Still need help?
Ask other Business Central users in the Insight Works community, or send the details to the support team. Include the steps you took and any error message you saw.