- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2017 10:29 AM
I was looking at updating the UI action to create an enhancement from a demand record to prepopulate fields. In looking at this particular UI action though, this looks like no other UI action that I've used before. It doesn't have any of the regular lines like task.description = current.description;
My question where do you specify what fields to auto fill in on the enhancement with info from the demand?
This is our OOB create enhancement UI on the demand table.
if( current.type == 'enhancement' ){
var demandUtil = new AjaxCreateRelatedEntityFromDemand();
var resultAsObject = true;
var enhancementObj = demandUtil.createEnhancement(current.sys_id, resultAsObject);
var enhancementId = enhancementObj.sys_id;
var number = enhancementObj.number;
var displayLabel = enhancementObj.label;
var enhancement;
var message;
var link;
if (enhancementId) {
enhancement = new GlideRecord('rm_enhancement');
enhancement.addQuery("sys_id", enhancementId);
enhancement.query();
if(enhancement.next()){
link =' <a href ="/rm_enhancement.do?sysparm_query=number%3D' + number + '">'+ number +'</a>';
message = gs.getMessage("{0} {1} has been created");
message = message.replace("{0}", displayLabel);
message = message.replace("{1}", link);
gs.addInfoMessage(message);
}
} else {
message = gs.getMessage("Error creating {0}");
message = message.replace("{0}", displayLabel);
gs.addErrorMessage(message);
}
action.setRedirectURL(current);
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2017 10:32 AM
Inside the createEnhancement method of the AjaxCreateRelatedEntityFromDemand Script Include. Lines 30 and 31 are using setValue to set the short_description and parent, as examples.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2017 10:32 AM
Inside the createEnhancement method of the AjaxCreateRelatedEntityFromDemand Script Include. Lines 30 and 31 are using setValue to set the short_description and parent, as examples.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2017 10:56 AM
guess that was easy. Just used to looking at UI actions that had everything right in the action and reference a script include. Is there any harm in updating this script include to prepopulate more fields? it will get missed in future updates as we've changed it from OOB?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
07-11-2017 10:58 AM
You could always "extend" the Script Include and write your own version of the existing methods, in order to safeguard the OOB code.
Here's a link to the developer training site, which explains how to extend a Script Include.