Field validation

priyanka1028
Tera Contributor

Hi Team,

 

I have one table name "Risk" there is a field " Planned_end_date" and on related list there are 3 risk response task tables which are having same name field "Planned_end_date".

When user select "planned_end_date" any of the 3 risk response task tables then it should check whether it is less than "planned_end_date" on risk table.

 

How to achieve this requirement?

2 REPLIES 2

Community Alums
Not applicable

Hi @priyanka1028 ,

 

You can write an On change client script on Risk Response task tables & call script include to query risk table and compare planned end dates.

 

If my answer helped you in any way, please mark it as helpful or correct.

Hayo Lubbers
Kilo Sage

Hi @priyanka1028 ,

 

If you have a display business rule on the response task table, filling the planned end_date of your risk on the scratchpad. You can then with a client script quick and easy check if the date is before that stored date.

 

The query in the business rule is executed serverside and therefor more efficient then everything client side.

More information : https://docs.servicenow.com/bundle/washingtondc-api-reference/page/script/client-scripts/concept/cli...

 

Something like this for your display business rule for the Risk Response Task table (sn_risk_response_task):

(function executeRule(current, previous) {
    var grRisk = new GlideRecord("sn_risk_risk");
    if (grRisk.get(current.getValue('risk'))) {
        scratchpad.risk_end_date = grRisk.getValue("<your end_date_fieldname>");
    }
})(current, previous);

 and then compare the values in your client script.