This can be done without scripting by using Runtime Events and DVM Rules.
Create a DVM Rule by navigating to Administration- DataValidation Screen
- Create a Validation Message with below values.
- Message Code: TEST-1101
- Message Level: Service Request
- Message Source: Action
- Message Text: Please close all activities first.
- Create a DVM Rule with following values.
- Name: SR Activities Validation
- Business Component: Service Request
- In Rules Applet, Create a Rule with following values.
- Sequence: 1
- Name: Check All Activities
- Expression: NOT(BCHasRows ("Service Request", "Action", "[Activity SR Id]='"+[Id]+"' AND [Status]<>'Closed'", "All"))
- Business Component: Service Request
- Apply To: Current Record
- Retun Code: TEST-1101
- Immediate Display: True (in Rule Detail Applet)
- Activate the Rule by clicking Activate Button.
Step 2: Create Runtime Event
Create a Action Set by navigating to Administation- RuntimeEvents Screen.
- Create an Action set with below values
- Name: Validate SR Activities
- Action Type: BusService
- Conditional Expression: [Status]='Closed'
- Business Service Name: Data Validation Manager
- Business Service Method: Validate
- Business Service Context: "Rule Set Name", "<DVM Rule Created in Step1>", "Enable Log", "Y"
- Create a Event with following values
- Sequence:1
- Object Type: BusComp
- Object Name:Service Request
- Event: PreWriteRecord
- Action Set Name: Validate SR Activities
- Reload Runtime Events.
In Application go to Service Requests and Test the DVM Rule. It will throw error message if we try to close a SR if activities are not closed as shown in below picture.
No comments:
Post a Comment