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.

How to get the version values for child article from Kb Knowledge table using business rule

String
Kilo Sage

I'm trying to create a child article from parent and trying to fetch the version value from the child article .So am using business rule :

1.When after 

2.Insert

3.Kb_knowledge

 

In advance ,below is the simple code 

 

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

 gs.info("Checking KB log" + current.getDisplayValue("version"))

})(current, previous);

 

But am unable to get the version ,Please guide me 

If version will take  time to load in Kb_Knowledge table ?

5 REPLIES 5

Amit Gujarathi
Giga Sage
Giga Sage

HI @String ,
I trust you are doing great.
Here’s a modified version of your script with additional logging. This might help in understanding what data is available at the time of the rule execution:

(function executeRule(current, previous /*null when async*/) {
    // Log current record to see all available fields
    gs.info("Current KB Record: " + JSON.stringify(current));

    // Check if version is available
    var version = current.getValue("version");
    if (version) {
        gs.info("Version: " + version);
    } else {
        gs.info("Version not available at this point");
    }
})(current, previous);

Was this answer helpful?


Please consider marking it correct or helpful.


Your feedback helps us improve!


Thank you!


Regards,


Amit Gujrathi