Trying to extend an existing script include

Ahmet1
Tera Expert

We are trying to customize the script include "AppointmentBookingImpl" by amending one word that appears in the work notes when an appointment booking request is submitted on the portal.

 

In this script include, right at the bottom is the following code 

generateScheduleWorknotes:function(taskGR, start, end, timezone, reschedule){
		var actual_start = new GlideDateTime();
		var actual_end = new GlideDateTime();						
		actual_start.setDisplayValueInternal(start);
		actual_end.setDisplayValueInternal(end);
		if (reschedule){
			taskGR.comments = gs.getMessage("Appointment is rescheduled to {0} - {1} ({2})",[actual_start.getDisplayValue(),actual_end.getDisplayValue(), timezone]);
		} else {	
			taskGR.comments = gs.getMessage("Appointment is scheduled for {0} - {1} ({2})",[actual_start.getDisplayValue(),actual_end.getDisplayValue(), timezone]);
		}
		
	},
	type: 'AppointmentBookingImpl'
};

 

Where it says "Appointment is scheduled for" , we are trying to make this "Appointment is requested for" as we have built a custom appointment approval process in place.

 

For guidance, I have used How to extend an existing Class in a new script include - Support and Troubleshooting - Now Support ...

 

I've come up with the following script include which is not working.

var AppointmentBookingImpl2 = Class.create();
AppointmentBookingImpl2.prototype = Object.extendsObject(AppointmentBookingImpl,

{ 
    generateScheduleWorknotes: function (taskGR, start, end, timezone, reschedule) {
        var actual_start = new GlideDateTime();
        var actual_end = new GlideDateTime();
        actual_start.setDisplayValueInternal(start);
        actual_end.setDisplayValueInternal(end);
        if (reschedule) {
            taskGR.comments = gs.getMessage("Appointment is rescheduled to {0} - {1} ({2})", [actual_start.getDisplayValue(), actual_end.getDisplayValue(), timezone]);
        } else {
            taskGR.comments = gs.getMessage("Appointment is requested for {0} - {1} ({2})", [actual_start.getDisplayValue(), actual_end.getDisplayValue(), timezone]);
        }
    },
    type: "AppointmentBookingImpl",

}); 

 

 

 

 

1 ACCEPTED SOLUTION

Slava Savitsky
Giga Sage

You don't have to extend the script include for this. All you need to do is update the record in the Messages [sys_ui_message] table where Key = Appointment is scheduled for {0} - {1} ({2})

If there is no record with this Key, simply create one.

View solution in original post

8 REPLIES 8

Hi Sandeep, I appreciate your help. Whilst you did indicate where to look, it wasn't the actual solution. The Sys UI Messages table did not have the key existing in there for this message and Slava clarified that I had to create it with the key value given to be able to create the message. 

Ah, my bad I didn't mention the key creation part.

Slava Savitsky
Giga Sage

You don't have to extend the script include for this. All you need to do is update the record in the Messages [sys_ui_message] table where Key = Appointment is scheduled for {0} - {1} ({2})

If there is no record with this Key, simply create one.

Hi Salva,

and if I have another modification (other than just a message) and I need to extend the script include, how to do it pleas?