Stockrooms for new orders
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2024 07:46 AM
What is possibly over a year ago, our HAM manager and one of the devs set up a script in the request workflow of equipment orders that if an order is place with a 'Non Work location' that it would create a stockroom (which also creates a location) for this order. A year later and we have over 250 locations and stock rooms that have a name prefix of 'Created for Request...'.
The parties in question have both left the company quite a while ago, and not being a HAM expert, I am trying to figure out the logic behind this. Is there a limitation on an order that requires a stockroom? Would it not have been a better idea to have a temp 'Holding' stockroom (and associated location) for these orders? If this is a requirement, then at what point can we possibly trigger a clean up of the created stockroom? Assume that everything else is OOB in the process (which is probably a bad assumption, but we are trying to get there and want as OOB a solution as possible).
Sorry if this seems like a odd issue, but our company seems to have like to take odd avenues to solve (or create) problems...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-02-2024 07:49 AM
just incase you would like to see the script (or is this an OOB script?)
var reqSysId = current.sys_id;
var reqNumber = current.number;
var attentionTo = current.variables.epoint_purchase_attention;
var jhprv_address1_slt = current.variables.jhprv_address1_slt;
var jhprv_address2_slt = current.variables.jhprv_address2_slt;
var jhprv_address3_slt = current.variables.jhprv_address3_slt;
var jhprv_town_slt = current.variables.jhprv_town_slt;
var jhprv_region_slt = current.variables.jhprv_region_slt;
var jhprv_postal_code_slt = current.variables.jhprv_postal_code_slt;
var jhprv_country = current.variables.jhprv_country;
var jhprv_alternative_address_cb = current.variables.jhprv_alternative_address_cb;
var epoint_purchase_shipping = current.variables.epoint_purchase_shipping;
function getRitms(reqSysId){
var ritmSysIdList = [];
gs.info('IH Update Transfer Order Lines to Requested ' + reqSysId);
var ritmGr = new GlideRecord("sc_req_item");
ritmGr.addQuery("request",reqSysId);
ritmGr.query();
while(ritmGr.next()){
var sysId = ritmGr.getValue("sys_id");
ritmSysIdList.push(sysId);
}
}
function checkForTransferLine(ritmSysId){
var tolSysId = '';
gs.info('IH Update Transfer Order Lines to Requested ' + ritmSysId);
var grTOL = new GlideRecord("alm_transfer_order_line");
grTOL.addEncodedQuery("request_line="+ritmSysId+"^stage=requested");
grTOL.query();
while(grTOL.next()) {
//gs.print('IH found transfer line ' + grTOL.number);
tolSysId = grTOL.sys_id;
gs.info('IH Update Transfer Order Lines to Requested found tolSysId ' + tolSysId);
updateTransferOrderLineTasks(tolSysId);
}
}
//Update Ready for fulfillment
function updateTransferOrderLineTasks(tolSysId){
var grTolTask = new GlideRecord("alm_transfer_order_line_task");
grTolTask.addEncodedQuery('transfer_order_line='+tolSysId+'^state=1');
gs.info('IH Update Transfer Order Lines to Requested found tolSysId updateTransferOrderLineTasks' + tolSysId);
grTolTask.query();
if (grTolTask.next()) {
gs.info('IH found transfer line ' + grTolTask.number);
grTolTask.description = 'Transfer approved';
grTolTask.state = 3;
grTolTask.update();
}
}
function createLocation(reqNumber){
var locGr = new GlideRecord("cmn_location");
locGr.name = 'Created for Request ' + reqNumber;
locGr.street = jhprv_address2_slt;
locGr.u_address_line_2 = jhprv_address3_slt;
locGr.city = jhprv_town_slt;
locGr.state = jhprv_region_slt;
locGr.country = jhprv_country;
locGr.zip = jhprv_postal_code_slt;
locGr.contact = attentionTo;
locGr.u_work_notes = "";
var locSysId = locGr.insert();
gs.info('IH Create Stockroom locSysId ' + locSysId);
createStockRoom(locSysId,reqNumber);
}
function createStockRoom(locSysId,reqNumber){
var stockGr = new GlideRecord("alm_stockroom");
stockGr.name = 'Created for Request ' + reqNumber;
stockGr.location = locSysId;
stockGr.external = true;
stockGr.manager = attentionTo;
var stockSysId = stockGr.insert();
}
createLocation(reqNumber);