Some PDIs are currently unavailable, and PDI actions are paused. View the latest updates here. Read More

Code issue, getxml wait no longer supported

Sunpreetk
Tera Contributor

 

This is script include:

var contractorOnboardingUtils = Class.create();

contractorOnboardingUtils.prototype = Object.extendsObject(global.AbstractAjaxProcessor, {

 

generateContractorId: function() {

var latestId = '';

var userGr = new GlideRecord('sn_hr_core_profile');

userGr.addQuery('u_contractor_id', 'STARTSWITH', 'CXP');

userGr.orderByDesc('u_contractor_id');

userGr.query();

if (userGr.next()) {

latestId = userGr.getValue('u_contractor_id');

}

return latestId;

},

 

type: 'contractorOnboardingUtils'

});

 

This is my onchange catalog client script

function onChange() {

var prefix = 'CXP';

var startingIndex = 100001;

 

// Fire GlideAjax but DO NOT block form submission

setTimeout(function() {

var ga = new GlideAjax('sn_hr_le.contractorOnboardingUtils');

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

ga.getXMLAnswer(function(latestId) {

var nextNumber;

 

if (latestId && latestId.length > 3) {

var numericPart = latestId.substring(3);

var numValue = parseInt(numericPart);

nextNumber = isNaN(numValue) ? prefix + startingIndex : prefix + (numValue + 1);

} else {

nextNumber = prefix + startingIndex;

}

 

g_form.setValue('u_contractor_id', nextNumber);

});

}, 10); // delay the call slightly

 

return true; // Allow the form to submit immediately

}

it says getxml wait not supported in portal. Please help me out i want to populate this contracor id field before or on form submission so that it get reflected in the description field of hr case.

0 REPLIES 0