function setContactForm(type) {
try {
// Corrected typo in variable name ‘typee’ to ‘type’
if (type === ‘create’) {
var form = nlapiGetFieldValue(‘customform’);
// Renamed GetUrlValue to match the actual function name getQueryVariable
var recordType = getQueryVariable(‘parentType’);
// If the form is already the desired one, stop the script
if (form == 178 && recordType == ‘vendor’) {
return;
}
if (form == 179 && recordType == ‘custjob’) {
return;
}
// Set Custom Form ID based on the record type
if (recordType == ‘vendor’) {
nlapiSetFieldValue(‘customform’, 178);
}
if (recordType == ‘custjob’) {
nlapiSetFieldValue(‘customform’, 179);
}
}
} catch (error) {
log.debug({ title: ‘Catch Error’, details: error });
}
}
// Function to retrieve query parameter value from URL
function getQueryVariable(tranId) {
var query = window.location.search.substring(1);
var params = query.split(‘&’);
for (var i = 0; i < params.length; i++) {
var pair = params[i].split(‘=’);
if (pair[0] == tranId) {
return pair[1];
}
}
}