- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2021 06:16 PM
Hello,
This relates to the change_request form.
On my Paris developer instance, I can see there is an annotation that has this text:
${new ChangeRequestDateMessage(current).getDateMsg()}
Which is rendered as follows:
I was unable to find any reference to this on the internet. Infact I couldn't find anything about dynamic annotations which I didn't realise was possible until now.
I am trying to debug this as it is no working on my company's instance, the text comes out empty:
Does anyone have some tips with how to debug this?
Solved! Go to Solution.
- Labels:
-
Personal Developer Instance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2021 06:22 PM
ChangeRequestDateMessage is the name of a script include.
Go to the Script include table and search for it.
Once you find it, you should look for the specific function with name getDateMsg

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2021 06:22 PM
ChangeRequestDateMessage is the name of a script include.
Go to the Script include table and search for it.
Once you find it, you should look for the specific function with name getDateMsg
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-03-2021 08:52 PM
Thank you. It turned out I didn't have this script include as part of my instance for some reason.
FYI:
https://[instance]/nav_to.do?uri=sys_script_include.do?sys_id=c59c8722677222004792adab9485ef51

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-15-2024 08:29 PM
Hi,
I'm interested in this solution, and dynamic annotation. I also don't have that script include on my instance. Are you able to post its contents?
Tim
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
06-10-2024 11:04 PM
not OP but here u go
var ChangeRequestDateMessage = Class.create();
ChangeRequestDateMessage.prototype = {
initialize: function(_gr) {
this.gr = _gr;
},
/**
* Gets the description message for the change request planned start/end date based on the state.
*
* @returns the message to display or empty string if not applicable
*/
getDateMsg: function() {
if (!this.gr)
return "";
var state = this.gr.getValue("state") - 0;
if (state === 4) // canceled
state = this._getPreviousState();
return this._getDateMessage(state);
},
_getDateMessage: function(state) {
var td = GlideTableDescriptor.get("change_request");
var startElement = td.getElementDescriptor("start_date");
var startLabel = startElement ? startElement.getLabel() : gs.getMessage("Planned start date");
var endElement = td.getElementDescriptor("end_date");
var endLabel = endElement ? endElement.getLabel() : gs.getMessage("Planned end date");
switch(state.toString()){
case "-5": // new
case "-4": // assess
case "-3": // authorize
return gs.getMessage("{0} and {1} are the requested change window", [startLabel, endLabel]);
case "-2": // scheduled
case "-1": // implement
case "0": // review
case "3": // closed
return gs.getMessage("{0} and {1} are the approved change window", [startLabel, endLabel]);
default:
return "";
}
},
_getPreviousState: function() {
var gr = new GlideRecord("sys_history_line");
gr.addEncodedQuery("field=state^set.id=" + this.gr.sys_id + "^set.table=change_request^ORDERBYDESCupdate");
gr.query();
if (gr.next())
return gr.getValue("old_value");
},
type: "ChangeRequestDateMessage"
};