How to set dynamic Status field on screen based on date range

By | February 28, 2022

In Sage X3, one of the client’s requirement was to have a dynamic “Policy Status” field which will reflect the current status where the policy is Active or De-active for the selected module. Here another condition was that at a given time span only one policy per module can be kept Active, rest will stay deactivated and will get activated automatically once the date condition is satisfied.

First to navigate to the screens that’ll be used for the below steps:

Window management: All -> Development -> Script dictionary -> Window management
Script editor: All -> Development -> Script dictionary -> Scripts -> Script editor
Tables: All -> Development -> Data and parameters -> Tables

To fulfill the above mentioned requirement we need to follow the below steps:

Step 1: Below are the locations showing the “Status and Applicable module” fields on screen, on window management and on the linked table of the screen. Refer the screenshots for reference:

New Stuff: Validation on the Sales order screen if credit limit exceeds

Module and Status fields on screen
Module and Status fields on screen
Status field under Header tab in Window management
Status field under Header tab in Window management
Status field in linked table of Header screen
Status field in linked table of Header screen

Step 2: For this customization we need to add some action events. The script code for the screen can be identified from Window management > Header screen > Specific script.

The logic for them will be as follows:
Once the user clicks the “New” button on screen to create a new policy and selects the Applicable Module our logic part will trigger that will check whether there is any existing Policy already for the given Module and if it does then whether it’s currently Active or Inactive.
In case the Policy exists and is Active, the Status field is made non-editable using the DISZO command followed by AFFZO command and set to DEACTIVE. Whereas if the Policy exists but is in Inactive status, then it’ll allow the user to select the status as per choice.

Case of Active existing Policy on module
Case of Active existing Policy on module

Step 3: Now when a new policy is created for a given date range, then another logic is added on the LIENS action event in script which gets triggered whenever the Entry no. is browsed from left list selection or opening the screen.

This logic checks if the current date is within the Policy date range first and then:
If the current date is within the date range then it’ll check if the status is Active or De-active.
For the Active case the logic will return from the event without any change.
For the De-active case the logic will check if there is any existing Active policy for the module, if not then it’ll change the status to ACTIVE on the screen and trigger an Update instruction on the table.

If the current date exceeds the To date of Policy:
For the Active case the logic will change the status to DEACTIVE and make the field non-editable using the DISZO command followed by AFFZO command, and update the table using the Update instruction.
For the De-active case logic will return from the event without any change.

This way we can dynamically set the status field on screen based on the policy date range.