Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Display Info /Error message in Project Workspace on planning Console on update of any field

Khushboo8
Tera Contributor

Hi All,

 

I am trying to display a error message on change of any field on project task in below Planning View on Project Workspace but it is not coming  using a Business Rule . It works fine in native end though. Please find the below screenshot:

Khushboo8_0-1748864141957.png


Business Rule Script : On update --Table Name : Pm_project_task

Script : 

(function executeRule(current, previous /*null when async*/) {

    // Add your code here

    gs.addInfoMessage('Test Message');

})(current, previous);

 

8 REPLIES 8

Vutikonda Vinay
Tera Contributor

UI policy with run script should be works other wise modify your business rule with this script

Type: Update

When to run : After

(function executeRule(current, previous /*null when async*/) {
    // Skip if we're in a background operation or loading
    if (current.isNewRecord() || gs.getEventName() == 'async') {
        return;
    }

    // Check if we're in a workspace context
    var isWorkspace = (typeof g_workspace !== 'undefined');
    
    // Get all changed fields
    var changes = current.getChanges();
    
    // If any fields changed
    if (changes && Object.keys(changes).length > 0) {
        var errorMsg = "Changes to project tasks require approval. Please submit a change request.";

 

Unfortunately this is not working 😞

Attila Beregvar
Kilo Sage

Have you found any solution to this since? I'm facing the same problem.

Vinay_97
Tera Contributor

Hi @Attila Beregvar

As earlier I said that UI Policy with Runscript should works and now I have taken a scenario with it and it is working fine in My PDI.

 

Scenario: Here I used on Incident form Impact is 1-High as a trigger condition to show the Error Message on SOW Workspace

UI Policy 

Vinay_97_0-1753622800190.png

Run Script

Vinay_97_1-1753622843162.png

 

Testing on SOW: When I change the Impact to 1-High shows me an error message

Vinay_97_2-1753622955960.png

 

I believe that if SOW workspace is working fine it works on other workspaces too.