How to edit 'Copy Change' UI Action

bhoomikabisht
Kilo Expert

Hi Experts,

I am working on Change management and want to modify 'Copy Change' UI Action

As per the requirement I want to copy two custom fields which i added added in the form. But I am not getting where to add the code in the UI Action. I checked the script include ChangeUtils. But not getting it.

Please help where i can modify.

Below is the UI Action:

function OnCopyChangeClick() {

  function addParam(form, name, val) {

  var inp = cel('textarea', form);

  inp.name = name;

  inp.value = val;

  }

  var srcSysId = g_form.getUniqueValue();

  var ga = new GlideAjax('ChangeUtils');

  ga.addParam('sysparm_name', 'getChangeQueryParams');

  ga.addParam('sysparm_src_sysid', srcSysId);

  ga.setWantSessionMessages(true);

  ga.getXMLAnswer(function (queryParam) {

  if (queryParam) {

  var gotoUrl = [];

  gotoUrl.push('srcSysID=' + srcSysId);

  gotoUrl.push('newSysID=$sys_id');

  gotoUrl.push('sysparm_returned_action=$action');

  gotoUrl = 'CopyChangeRelatedLists.do?' + gotoUrl.join('&');

  var form = cel('form', document.body);

  hide(form);

  form.method = "POST";

  form.action = g_form.getTableName() + ".do";

  if (typeof g_ck != 'undefined' && g_ck != "")

  addParam(form, 'sysparm_ck', g_ck);

  addParam(form, 'sys_id', '-1');

  addParam(form, 'sysparm_query', queryParam);

  addParam(form, 'sysparm_goto_url', gotoUrl);

  form.submit();

  }

  });

}

Below is the Script Includes:

var ChangeUtils = Class.create();

ChangeUtils.prototype = Object.extendsObject(ChangeUtilsSNC, {

  initialize: function(request, responseXML, gc) {

  ChangeUtilsSNC.prototype.initialize.call(this, request, responseXML, gc);

  },

  /***************************

  *

  *Add customer changes below

  *

  ****************************/

  type: 'ChangeUtils'

});

/********************************************************************

*The function below is written in this way to provide access via the

*signature ChangeUtils.isCopyChangeEnabled() from UI Action -

*'Copy Change' > Condition.

*

*Customers are suggested to override methods inside the body of

*ChangeUtils' object definition.

********************************************************************/

ChangeUtils.isCopyChangeEnabled = function(current) {

  var changeUtils = new ChangeUtils();

  if (changeUtils.isCopyFlagValid() && changeUtils.isCopyRulesValid(current)) {

  return true;

  } else {

  return false;

  }

};

Thanks & Regards,

Bhoomika Bisht

14 REPLIES 14

I believe all the scripting is based on the Change Request table.

I'm not sure if that works on Child Tables.

 

So if you want to copy that field, you may need to write your own scripting to copy it

Thanks Chris, Could you please help me with the scripting part

Thanks for the tip.

Jehiellb
Giga Contributor

Hi Steven,

 

How about the Related List? have you tried to copy a change with the related list in it? 
Can you help me how to add the Related list to Copy Change?

Your help will be much appreciated, Thanks in advance!

Lakshmi24
Tera Contributor

Hi,

 

I am looking for similar functionality for a custom table. When user clicks the 'copy form' custom UI button, It has to redirect the user to a new form and all the field values from the existing form should be copied to the new form without inserting/saving the form. So that user can update the fields if needed.

 

Please suggest how we can achieve this scenario. 

 

Thanks,

Lakshmi