While clicking on copy request button on portal one field is not auto populating .
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-08-2024 10:31 PM
Hi Team ,
i have issue, copying field, while i click on copy request all fields are autopopulated only cost center field is not populating,it is a lookup field with reference Qualifier: javascript:'location.u_region='+current.variables.region_requesting_functionality+'^location.country='+current.variables.country_requesting_functionality+'^u_active=true';
if i remove the reference Qualifier , the field is getting autopopulated. so how can i achieve to autopulate this field.
can some one help me on this.
client script:
function onLoad() {
var rec_id = getParameterValue('sp_copy_from');
if (rec_id) {
var ga = new GlideAjax('CopyVariablesUtils');
ga.addParam('sysparm_name', 'getRecordValues');
ga.addParam('rec_id', rec_id);
ga.getXMLAnswer(getValues);
}
}
function getValues(answer) {
alert(answer);
var data = JSON.parse(answer);
for (var i = 0; i < data.length; i++) {
g_form.setValue(data[i].name, data[i].value);
}
}
function getParameterValue(name) {
name = name.replace(/[\[]/, "\\\[").replace(/[\]]/, "\\\]");
var regexS = "[\\?&]" + name + "=([^&#]*)";
var regex = new RegExp(regexS);
var results = regex.exec(top.location);
if (results == null) {
return "";
} else {
return unescape(results[1]);
}
}
script include:
var CopyVariablesUtils = Class.create();
CopyVariablesUtils.prototype = Object.extendsObject(AbstractAjaxProcessor, {
getRecordValues: function() {
var rec_id = this.getParameter('rec_id');
var values = [];
var res = new GlideRecord('sc_item_option_mtom');
res.addEncodedQuery('request_item=' + rec_id + '^sc_item_option.valueISNOTEMPTY');
res.orderBy('sc_item_option.order');
res.query();
while (res.next()) {
var x = {};
var val = new GlideRecord('sc_item_option');
val.get('sys_id', res.getValue('sc_item_option'));
var name = new GlideRecord('item_option_new');
name.get('sys_id', val.getValue('item_option_new'));
x.name = name.getValue('name');
x.value = val.getValue('value');
values.push(x);
}
values = new global.JSON().encode(values);
return values;
},
type: 'CopyVariablesUtils'
});
0 REPLIES 0