We've updated the ServiceNow Community Code of Conduct, adding guidelines around AI usage, professionalism, and content violations. Read more

Cab date Shouldn't be after planned start date.

abidsiddiqu
Mega Guru

Hi Folks,

 

I have created a scenario where Cab date Shouldn't be after planned start date in Change Request.
It is giving me Erros even when I am selecting dates before Planned start date.

 

Please share your thoughts,
Thanks in advance.

 

Client Script -

AbidSiddiqui_0-1698032764790.png

 

Script Include -

AbidSiddiqui_1-1698033228991.png

 

 

 

 




7 REPLIES 7

Harish KM
Kilo Patron

Hi @abidsiddiqu You donot need client script and script include for this. You can have a Before update/insert BR on change request table

Cond: cabdate changes or cabdate is empty

Script:

if (current.cab_date_time > current.start_date )
{
    gs.addErrorMessage("Cab date Shouldn't be after planned start date");
    current.setAbortAction(true);
}
Regards
Harish

unfortunately, this is also not working,
Thanks for response though. 

Hi @abidsiddiqu I tested in PDI it works fine for me .

make sure field names and conditions are correct

Regards
Harish

Sagar Pagar
Tera Patron

Hi @abidsiddiqu,


I would suggest to use the UI policy for data validations instead of Client scripts.

 

Condition:

Cab date ISMORETHAN 0 HOURS AFTER Planned start date

 

Execute if true:

function onCondition() {
g_form.clearValue("cab_date_time");
g_form.showFieldMsg("cab_date_time", "Cab date Shouldn't be after planned start date in Change Request" , "error");
}

 

For reference:

Screenshot 2023-10-23 at 9.40.03 AM.png

 

Note: It will only allow Cab date before Planned state date.

 

If my response helps you resolve your issue. Kindly mark it as helpful & correct. It will be helpful to future readers! 👍🏻
Thanks,
Sagar Pagar

The world works with ServiceNow