A function to show an alert box while the status of the entity is the preferred status.
Here the status of the Vendor is expired, then show an alert box. The status of the vendor is fetched using lookup field function.
function showMessageBasedOnEntityStatus(id) {
try {
var entityStatus = search.lookupFields({
type: search.Type.VENDOR,
id: id, // id of the entity
columns: 'custentity_entity_status'
});
if (entityStatus.custentity_entity_status.length) { // if the entity has any status
var entityStatusId = entityStatus.custentity_entity_status[0].value // current status of the entity
if (entityStatusId == STATUS_EXPIRED) {
alert('The Receiving entity is Expired. Please do the necessary action.');
}
}
} catch (e) {
console.log('error@showMessageBasedOnEntityStatus', e);
}
}