Create Outage from Change with population of plan start and end dates

NS16
Mega Sage

Hi Experts,

 

I want to create "Outage" from change record and there is OOTB "Create Outage" UI action available and I want to populate begin date with planned start date and end date with planned end date by onclick on Create Outage.

 

OOTB Ci, task number and short description are populating from change request, in same way how can I populate begin and end date on outage record.

 

Create Outage UI action- 

NS16_0-1700117043895.png

 

Below is OOTB code

 

createOutageM2M();

function createOutageM2M() {
	var url = "cmdb_ci_outage.do?sys_id=-1&sysparm_query=";
	url += encodeURIComponent("cmdb_ci=" + current.getValue("cmdb_ci") + "^task_number=" + current.getUniqueValue() + "^short_description=" + current.getValue("short_description") + "^EQ");

	action.setRedirectURL(url);

 

 

Thanks in Advance,

NS

1 ACCEPTED SOLUTION

Anand Kumar P
Giga Patron
Giga Patron

Hi @NS16 ,

 

 

createOutageM2M();

function createOutageM2M() {
    var url = "cmdb_ci_outage.do?sys_id=-1&sysparm_query=";
    url += encodeURIComponent("cmdb_ci=" + current.getValue("cmdb_ci") + "^task_number=" + current.getUniqueValue() + "^short_description=" + current.getValue("short_description") + "^begin=" + current.getValue("start_date") + "^end=" + current.getValue("end_date") + "^EQ");

    action.setRedirectURL(url);
    action.setReturnURL(current);
}

 

 


Use above script its working in my pdi

 

AnandKumarP_0-1700118567479.png

 

AnandKumarP_1-1700118582714.png


Please mark it as helpful and solution proposed if it serves your purpose.

Thanks,

Anand

 

View solution in original post

3 REPLIES 3

Anand Kumar P
Giga Patron
Giga Patron

Hi @NS16 ,

 

 

createOutageM2M();

function createOutageM2M() {
    var url = "cmdb_ci_outage.do?sys_id=-1&sysparm_query=";
    url += encodeURIComponent("cmdb_ci=" + current.getValue("cmdb_ci") + "^task_number=" + current.getUniqueValue() + "^short_description=" + current.getValue("short_description") + "^begin=" + current.getValue("start_date") + "^end=" + current.getValue("end_date") + "^EQ");

    action.setRedirectURL(url);
    action.setReturnURL(current);
}

 

 


Use above script its working in my pdi

 

AnandKumarP_0-1700118567479.png

 

AnandKumarP_1-1700118582714.png


Please mark it as helpful and solution proposed if it serves your purpose.

Thanks,

Anand

 

Voona Rohila
Kilo Patron
Kilo Patron

Hi @NS16 

 

Try this

createOutageM2M();

function createOutageM2M() {
    var url = "cmdb_ci_outage.do?sys_id=-1&sysparm_query=";
    url += encodeURIComponent("cmdb_ci=" + current.getValue("cmdb_ci") + "^task_number=" + current.getUniqueValue() + "^short_description=" + current.getValue("short_description") + "^begin=" + current.getValue("start_date") + "^end=" + current.getValue("end_date") + "^EQ");

    action.setRedirectURL(url);
    action.setReturnURL(current);
}

 


Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Rohila V
2022-25 ServiceNow Community MVP

Dr Atul G- LNG
Tera Patron
Tera Patron

Hi @NS16 

 

I am happy you accepted the solution , but i have another thought. Don't populate the outage start / end with change start /date the reason begin,

- A change duration including pre requisite  task / actual deployment/ testing task as well.

- If you populate the change time to outage , means you are marking your app down / not available for whole duration which may be a case for every change.

 

Instead of this, put validation on Outage start date not less that plan start and can be grater than the plan end date. 

*************************************************************************************************************
If my response proves useful, please indicate its helpfulness by selecting " Accept as Solution" and " Helpful." This action benefits both the community and me.

Regards
Dr. Atul G. - Learn N Grow Together
ServiceNow Techno - Functional Trainer
LinkedIn: https://www.linkedin.com/in/dratulgrover
YouTube: https://www.youtube.com/@LearnNGrowTogetherwithAtulG
Topmate: https://topmate.io/atul_grover_lng [ Connect for 1-1 Session]

****************************************************************************************************************