help needed having issues in creating interactions in the walkup location queue.

chercm
Mega Sage

hi would need some help as i am having issue in getting the interactions created after scanning the serial number of the laptop using the service portal widget. i understand i need to use the facade function not sure is that true as i have tried to use the table method to create but it is not displaying in the correct walkuplocation queue 

 

interaction.initialize();
 
interaction.opened_for = alm_hardware.assigned_to;
interaction.location = alm_hardware.location; // Assuming 'location' is a field on the hardware table
interaction.reason = "Laptop refresh";
 
return interaction.insert();

 

(function ($sp, options, input, data) {
if (barCodeScanned(input)) {
var interactionSysId = lookUpAssetAndCreateInteraction(input.barCode);
if (interactionSysId) {
// Interaction successfully created, optionally perform additional actions
data.interactionSysId = interactionSysId;
} else {
// Handle the case where interaction creation failed
data.error = gs.getMessage('Failed to create a walk-up interaction.');
}
} else {
// Handle the case where the barcode is not scanned
data.error = gs.getMessage('Barcode not scanned.');
}
function barCodeScanned(input) {
return input && input.barCode;
}
function lookUpAssetAndCreateInteraction(barCode) {
var alm_hardware = new GlideRecord('alm_hardware');
if (alm_hardware.get('serial_number', barCode)) {
if (facade) {
var newInteraction = facade.createInteraction();
newInteraction.short_description = "Walk-up Interaction";
newInteraction.description = "Laptop refresh";
newInteraction.u_walkup_location = "Singapore"; // Update with the correct walk-up location
var interactionSysId = facade.saveInteraction(newInteraction);
if (interactionSysId) {
// Interaction successfully saved, optionally perform additional actions
facade.openInteraction(interactionSysId);
return interactionSysId;
} else {
// Handle the case where interaction save failed
gs.error("Error: Failed to save the walk-up interaction.");
return null;
}
} else {
// Handle the case where the facade is not initialized
gs.error("Error: Walk-up Interaction Facade not initialized.");
return null;
}
} else {
// Handle the case where the hardware record was not found
gs.error("Error: Hardware record not found for serial number: " + barCode);
data.error = gs.getMessage('Hardware record not found for serial number: {0}', barCode);
return null;
}
}
})($sp, options, input, data);

1 REPLY 1

chercm
Mega Sage

help needed please