| 1 |
|
|
|
|
|
|
var desc = [];
var map = [
'TUB_CATEGORY',
'DRAIN_TUB',
'TYPE_JET',
'STYLE_SKIRT',
'TRIM_TUB',
'SIZE_TUB',
'COLOR_TUB'
];
map.forEach(function (q) {
if (isAnswered(q)) {
desc.push(getAnswerCode(q));
}
});
// -- set it to UI
setValue('SKU', 'VAL', desc.join('-')); |
Custom SCPQ-Operation Form |
17 |
|
F |
1 |
10/15/2018 1:52 pm |
Description Builder |
|
|
Tom Unterfenger |
5 |
true |
CPQ_00003 Remodel Kingdom Bathtubs |
3 |
49 |
|
|
*/* |
F |
F |
val_20192_3701406_876 |
1 |
customrecord_scpq_operation |
|
rectype=49&e=T&id=1 |
1 |
Description Builder |
|
5 |
SCPQ-Action |
|
customrecordentry |
49 |
F |
custrecordentry |
2 |
| 2 |
|
|
|
|
|
SELECT_MIRROR |
setAnswer("ADDON_VANITY", "VANITY_MIRROR"); |
Custom SCPQ-Operation Form |
17 |
|
F |
2 |
9/6/2018 3:52 pm |
Select Mirror |
|
|
Tom Unterfenger |
5 |
_("COLOR_VANITY_BOTTOM/*") |
CPQ_00005 Vanity Sets |
5 |
49 |
|
|
COLOR_VANITY_BOTTOM/* |
F |
F |
val_22798_3701406_703 |
1 |
customrecord_scpq_operation |
|
rectype=49&e=T&id=2 |
2 |
Select Mirror |
|
5 |
SCPQ-Action |
|
customrecordentry |
49 |
F |
custrecordentry |
|
| 3 |
|
|
|
|
|
SHOW_RESULTS |
var searchValue = sw.fns.buildClassName();
var usingPN = false;
var searchType = getAnswerCode('RUN_SEARCH');
var qTable = getQTable('RESULTS');
reset('RUN_SEARCH');
if (hasAnswer('SEARCH_BY_SKU', 'SKU')) {
searchValue = getValue('SEARCH_BY_SKU', 'SKU');
usingPN = true;
}
if (usingPN) {
sw.fns.findItemsByPartNumber(searchValue).done(function (items) {
if (items.length) {
setParts(items);
} else {
clearTable('Could not find items matching ' + searchValue);
}
});
} else {
sw.fns.findClassIdByName(searchValue).done(function (res) {
if (res.length) {
setValue('CLASS_NAME', 'VAL', res[0].id);
sw.fns.findItemsByClassID(res[0].id, searchType).done(function (items) {
if (items.length) {
setParts(items);
} else {
clearTable('Could not find items with class ' + res[0].id);
}
});
} else {
console.log('Could not find class ID');
}
});
}
function setParts(items) {
console.log('Found', items.length, 'accessories', items);
qTable.setRowCount(items.length);
items.forEach(function (r, i) {
var sl = r.sublists;
var pricing = sl.price1;
var price = pricing.length && pricing[0].price ? pricing[0].price : 'Price not found';
qTable.set('PN', (i + 1), r.itemid);
qTable.set('DESC', (i + 1), (r.salesdescription || r.purchasedescription));
qTable.set('PRICE', (i + 1), price);
setTimeout(function () {
displayImg(r.itemid, (i + 1));
}, 100);
});
}
function clearTable(msg) {
msg && console.warn(msg);
qTable.setRowCount(0);
qTable.clear();
}
function displayImg(pn, idx) {
var imgData = sw.partImages.getBySKU(pn);
var src = '';
var el = $('[id="sole-RESULTS-IMG_' + idx + '"]');
if (imgData) {
src = imgData['1'];
el.css({
'background' : 'url(' + src + ')',
'background-position-y' : 'center',
'background-position-x' : 'center',
'background-size' : '50%', //'100%',
'background-repeat' : 'no-repeat'
});
}
} |
Custom SCPQ-Operation Form |
17 |
|
F |
3 |
3/28/2019 4:23 pm |
Search and Show Accessory Results |
|
|
Tom Unterfenger |
5 |
_("RUN_SEARCH/*") |
CPQ_00009 Accessories |
9 |
49 |
|
|
RUN_SEARCH/* |
F |
F |
val_25939_3701406_446 |
100 |
customrecord_scpq_operation |
|
rectype=49&e=T&id=3 |
3 |
Search and Show Accessory Results |
|
5 |
SCPQ-Action |
|
customrecordentry |
49 |
F |
custrecordentry |
42 |
| 4 |
|
|
|
|
|
LEVEL_3 |
reset("LEVEL_3"); |
Custom SCPQ-Operation Form |
17 |
|
F |
4 |
10/23/2018 7:52 pm |
Reset Level 3 |
|
|
Tom Unterfenger |
5 |
!(_("LEVEL_2/*")) |
CPQ_00009 Accessories |
9 |
49 |
|
|
LEVEL_2/%% |
F |
F |
val_25940_3701406_111 |
4 |
customrecord_scpq_operation |
|
rectype=49&e=T&id=4 |
4 |
Reset Level 3 |
|
5 |
SCPQ-Action |
|
customrecordentry |
49 |
F |
custrecordentry |
|
| 5 |
|
|
|
|
|
LEVEL_2 |
reset("LEVEL_2"); |
Custom SCPQ-Operation Form |
17 |
|
F |
5 |
10/23/2018 7:53 pm |
Reset Level 2 |
|
|
Tom Unterfenger |
5 |
!(_("LEVEL_1/*")) |
CPQ_00009 Accessories |
9 |
49 |
|
|
LEVEL_1/%% |
F |
F |
val_25941_3701406_462 |
2 |
customrecord_scpq_operation |
|
rectype=49&e=T&id=5 |
5 |
Reset Level 2 |
|
5 |
SCPQ-Action |
|
customrecordentry |
49 |
F |
custrecordentry |
|
| 6 |
|
|
|
|
|
NS_ITEM_RES |
|
Custom SCPQ-Operation Form |
17 |
|
F |
6 |
11/6/2018 5:11 pm |
NS Item Master Query |
|
|
Tom Unterfenger |
5 |
_("LEVEL_1/*") |
|
|
49 |
|
|
LEVEL_1/* |
F |
F |
val_26054_3701406_157 |
999 |
customrecord_scpq_operation |
|
rectype=49&e=T&id=6 |
6 |
NS Item Master Query |
|
5 |
SCPQ-Action |
|
customrecordentry |
49 |
F |
custrecordentry |
1 |
| 7 |
|
|
|
|
|
SW_NS |
window.sw = window.sw || {};
window.sw.itemFieldsForReturn = ['itemid', 'salesdescription', 'isinactive', 'class', 'purchasedescription'];
window.sw.fns = window.sw.fns || {}
/**
*
* Desc: Returns classname to use as filter
* @return {string} - class name
*
*/
window.sw.fns.buildClassName = function (fields) {
var levels = 4;
var changeMap = {
'BATHROOM' : 'BATHROOM',
'SHOWER' : 'SHOWER',
'KITCHEN' : 'KITCHEN'
};
var name = '';
for (var i = 1; i <= levels; i++) {
if (isAnswered('LEVEL_' + i)) {
if (changeMap[getAnswerCode('LEVEL_' + i)]) {
name = changeMap[getAnswerCode('LEVEL_' + i)];
} else {
name = getAnswerName('LEVEL_' + i);
}
}
}
console.log('Class is', name);
return name;
};
/**
*
* Desc: Returns base and custom item records fields
*
* @param fields {Array} - Array of fields to get in addition
* to the base fields;
* @return {array} - fields to retrieve from item records
*
*/
window.sw.fns.getItemRecordFields = function (fields) {
if (!fields) {
fields = [];
}
return window.sw.itemFieldsForReturn.concat(fields);
};
/**
*
* Desc: Takes class ID and queries NS item master
* returning items matching the class
*
* @param id {string} - NS id to search by
*
* @return {array} - List of items matching the class
*
*/
window.sw.fns.findItemsByClassID = function (id, type) {
var typeMap = {
'INV': 'inventoryitem',
'KIT': 'kititem'
};
var recordType = typeMap[type];
console.log('Searching', recordType,'records');
return getData({
type : recordType,
filter : ['class', 'is', id],
fields : window.sw.fns.getItemRecordFields(),
async : false,
loadapi: true,
sublists : {
price1 : ['price']
}
});
};
/**
*
* Desc: Takes part number and queries NS item master
* returning items containing the value
*
* @param pn {string} - NS part number to search with
*
* @return {array} - List of items matching the class
*
*/
window.sw.fns.findItemsByPartNumber = function (pn) {
return getData({
type : 'inventoryitem',
filter : ['itemid', 'contains', pn],
fields : window.sw.fns.getItemRecordFields(),
async : false,
sublists : {
price1 : ['price']
}
})
};
/**
*
* Desc: Takes name and returns NS class ID
*
* @param id {string} - NS name to search by
*
* @return {Object} - Deferred object with results
* { id: <id>, name: <name> }
*
*/
window.sw.fns.findClassIdByName = function (name) {
return getData({
type : 'classification',
async : false,
filter : ['namenohierarchy', 'is', name],
fields : ['namenohierarchy', 'name', 'externalid', 'subsidiary', 'isinactive']
});
};
window.sw.partImages = (function () {
var imgData = loadListKeyValue('IMAGES');
var keyedImgData = imgData.reduce(function (acc, curr) {
acc[curr.SKU] = {
'1' : curr.PRIMARY_1,
'2' : curr.PRIMARY_2,
'3' : curr.PRIMARY_3
}
return acc;
}, {});
return {
view : function () {
console.log('data', imgData);
console.log('keys', keyedImgData);
},
getBySKU : function (sku) {
return keyedImgData[sku];
}
}
})(); |
Custom SCPQ-Operation Form |
17 |
|
F |
7 |
3/28/2019 4:09 pm |
SW Namespace |
|
|
Tom Unterfenger |
5 |
(__["SOLE/CFGSTATUS"]=="STARTUP") |
CPQ_00009 Accessories |
9 |
49 |
|
|
SOLE/CFGSTATUS[="STARTUP"] |
F |
F |
val_26055_3701406_955 |
5 |
customrecord_scpq_operation |
|
rectype=49&e=T&id=7 |
7 |
SW Namespace |
|
5 |
SCPQ-Action |
|
customrecordentry |
49 |
F |
custrecordentry |
15 |
| 8 |
|
|
|
|
|
BREAKOUT |
console.log('*** Item Breakout ***');
var qTable = getQTable('RESULTS');
var rowsFilled = qTable.getFilledRowCount();
for (var i = 1; i <= rowsFilled; i++) {
var pn = qTable.get('PN', i);
var qty = qTable.get('QTY_ORDERED', i);
var price = qTable.get('PRICE', i);
console.log(qty)
if (qty && price != 'Price not found') {
console.log('Ordering qty =>', qty, 'of', pn, 'at price', price);
addBreakoutItem({
sku: pn,
qty: qty,
price: price
});
}
} |
Custom SCPQ-Operation Form |
17 |
|
F |
8 |
12/19/2018 4:15 pm |
Breakout Items |
|
|
Tom Unterfenger |
5 |
(__["SOLE/CFGSTATUS"]=="FINAL") |
CPQ_00009 Accessories |
9 |
49 |
|
|
SOLE/CFGSTATUS[="FINAL"] |
F |
F |
val_26079_3701406_360 |
10000 |
customrecord_scpq_operation |
|
rectype=49&e=T&id=8 |
8 |
Breakout Items |
|
5 |
SCPQ-Action |
|
customrecordentry |
49 |
F |
custrecordentry |
10 |
| 9 |
|
|
|
|
|
SKU / Pricing |
(function () {
var model = getAnswerCode('MODEL_MEDITUB');
var modelMap = {
WCA : 'WCA',
STEPIN : 'SI',
WALKIN : ''
};
var size = getAnswerCode('SIZE_MEDITUB');
var drainOrientation = getAnswerCode('ORIENTATION_DRAIN');
var drainMap = {
RIGHT : 'R',
LEFT : 'L',
CENTER : 'C'
};
var color = getAnswerCode('COLOR_MEDITUB');
var colorMap = {
BISCUIT : 'B',
WHITE : 'W'
};
var tubFunction = getAnswerCode('FUNCTION_MEDITUB');
var tubFunctionMap = {
SOAKER : 'S',
AIR : 'A',
HYDRO : 'H',
DUAL : 'D'
}
var sku = '';
var imgSku = '';
var pricingData = loadListKeyValue('TUB_PRICING');
// -- remove all but numbers from size
if (checkValue(size)) {
size = size.replace(/\D+/g, '');
} else {
size = '';
}
sku += size;
imgSku += size;
if (checkValue(model)) {
sku += modelMap[model];
if (model == 'WALKIN' && size == '3060') {
sku += 'WI';
}
imgSku += modelMap[model] || 'WI';
}
imgSku += '-';
if (checkValue(drainOrientation)) {
sku += drainMap[drainOrientation] || 'L';
imgSku += drainMap[drainOrientation] || 'L';
}
imgSku += '_DRW.jpg';
if (checkValue(color)) {
sku += colorMap[color] || 'W';
}
if (checkValue(tubFunction)) {
sku += tubFunctionMap[tubFunction] || 'S';
}
console.log('SKU is', sku);
setValue('OUTPUT', 'BASE_SKU', sku);
setValue('SOLE', 'DESC', sku);
setValue('OUTPUT', 'IMG_SKU', imgSku);
var priceRes = pricingData.filter(function (item) {
return item.PN == sku;
});
reset('PRICING');
reset('SPECS');
if (priceRes.length) {
priceRes = priceRes[0];
setValue('PRICING', 'COST', priceRes.COST);
setValue('PRICING', 'MAP', priceRes.MAP);
setValue('PRICING', 'MSRP', priceRes.MSRP);
setValue('PRICING', 'SELL', priceRes.COST / 0.75);
['NAME', 'WEIGHT', 'HEIGHT', 'WIDTH', 'DEPTH', 'SOAK_DEPTH', 'DIMENSIONS', 'LEAD_TIME'].forEach(function (a) {
setValue('SPECS', a, priceRes[a]);
});
} else {
console.warn('Could not find price for', sku);
setValue('PRICING', 'NO_PRICE', sku);
$scope.showValidations();
}
function checkValue(val) {
var nf = 'ANS CODE NF';
return val && typeof val == 'string' && val !== nf;
}
})(); |
Custom SCPQ-Operation Form |
17 |
|
F |
9 |
2/4/2019 2:46 pm |
Base SKU for pricing |
|
|
Tom Unterfenger |
5 |
_("COLOR_MEDITUB/*") |
CPQ_00011 Meditub |
11 |
49 |
|
|
COLOR_MEDITUB/* |
F |
F |
val_26464_3701406_779 |
1 |
customrecord_scpq_operation |
|
rectype=49&e=T&id=9 |
9 |
Base SKU for pricing |
|
5 |
SCPQ-Action |
|
customrecordentry |
49 |
F |
custrecordentry |
22 |
| 10 |
|
|
|
|
|
ADDON_PRICING |
/**
*
* Description: Loads add on pricing data and adds pricing if an add on is selected
*
**/
var addOnPricing = loadListKeyValue('ADD_ONS');
addOnPricing.filter(function (a) {
return a.Q_CODE && a.A_CODE;
}).forEach(function (addOn) {
var q = addOn.Q_CODE;
var a = addOn.A_CODE;
var desc = addOn.DESC;
var cost = +addOn.COST;
var mgnPct = 0.25;
var prc = cost / (1 - mgnPct);
console.log(q,a, hasAnswer(q,a));
if (hasAnswer(q, a)) {
setValue('PRICING', a, prc);
} else {
console.log('resetting', a);
reset('PRICING', a);
}
}); |
Custom SCPQ-Operation Form |
17 |
|
F |
10 |
12/7/2018 5:25 pm |
Add On Pricing |
|
|
Tom Unterfenger |
5 |
true |
CPQ_00011 Meditub |
11 |
49 |
|
|
*/* |
F |
F |
val_84159_3701406_392 |
2 |
customrecord_scpq_operation |
|
rectype=49&e=T&id=10 |
10 |
Add On Pricing |
|
5 |
SCPQ-Action |
|
customrecordentry |
49 |
F |
custrecordentry |
7 |
| 11 |
|
|
|
|
|
DRAWING_URL |
window.cpiImages = window.cpiImages || function () {
var hasLoaded = false;
var imgMap = {};
var searchData = {
type : 'file',
filter : ['folder', 'is', '1336'],
fields : ['name', 'url', 'fileType']
};
function findImage() {
var imgSku = getValue('OUTPUT', 'IMG_SKU');
reset('OUTPUT', 'IMG_URL');
var imgUrl = '';
if (imgSku) {
imgUrl = cpiImages.getImageUrl(imgSku);
if (imgUrl) {
setValue('OUTPUT', 'IMG_URL', imgUrl);
} else {
console.warn('Could not find image url for', imgSku);
}
}
}
getData(searchData).done(function (imgs) {
hasLoaded = true;
if (imgs && imgs.length) {
imgs.forEach(function (img) {
var url = img.url;
var name = img.name;
imgMap[name] = url;
});
findImage();
scopeRefresh();
}
});
return {
getImageUrl : function (sku) {
var ret = '';
if (this.isReady() && (sku in imgMap)) {
ret = imgMap[sku];
}
return ret;
},
isReady : function () {
return hasLoaded;
},
findImg: function () {
return findImage();
}
}
}
();
window.cpiImages.findImg(); |
Custom SCPQ-Operation Form |
17 |
|
F |
11 |
12/18/2018 2:21 pm |
Drawing URL |
|
|
Tom Unterfenger |
5 |
true |
CPQ_00011 Meditub |
11 |
49 |
|
|
*/* |
F |
F |
val_84172_3701406_210 |
3 |
customrecord_scpq_operation |
|
rectype=49&e=T&id=11 |
11 |
Drawing URL |
|
5 |
SCPQ-Action |
|
customrecordentry |
49 |
F |
custrecordentry |
7 |
| 12 |
|
|
|
|
|
SKU_BUILDER |
/**
*
* SKU convention is - size + model + function + pump orient
*
**/
(function () {
var size = getAnswerCode('SIZE_ATLANTIS');
var model = getAnswerCode('MODEL_ATLANTIS');
var fn = getAnswerCode('FUNCTION_ATLANTIS');
var fnMap = {
SOAKER: '',
AIR:'A',
HYDRO: 'W',
DUAL: 'D'
};
var orient = getAnswerCode('ORIENTATION_PUMP');
var drainMap = {
RIGHT : 'R',
LEFT : 'L',
CENTER : 'C'
};
var sku = '';
var imgSku = '';
var modelName = getAnswerName('MODEL_ATLANTIS');
imgSku += modelName;
imgSku += '-';
// -- remove all but numbers from size
if (checkValue(size)) {
size = size.replace(/\D+/g, '');
imgSku += size;
} else {
size = '';
}
sku += size;
if (checkValue(model)) {
sku += getModelPriceCode(model);
imgSku += getModelPriceCode(model);
}
if (checkValue(fn)) {
if (model == 'PETITE' && size == '4478') {
sku += 'C';
}
sku += fnMap[fn] || '';
if ((model == 'SUISSE' || model == 'AQUARIUS' || model == 'ROYALE' || model == 'BREEZE' || model == 'EMBRACE' || model == 'REEF') && fn == 'SOAKER') {
sku += 'S';
}
}
if (checkValue(orient)) {
sku += drainMap[orient];
}
imgSku += '_DRW.jpg';
var specialSku = hasSpecialSuffix(model)
if (specialSku.hasSpecial) {
sku += specialSku.sku; //'SXCWXX';
}
console.log('SKU is', sku);
if (isAnswered('FUNCTION_ATLANTIS')) {
setValue('OUTPUT', 'SKU', sku);
setValue('SOLE', 'DESC', sku);
} else {
reset('OUTPUT', 'SKU');
reset('SOLE', 'DESC');
}
setValue('OUTPUT', 'IMG_SKU', imgSku);
function checkValue(val) {
var nf = 'ANS CODE NF';
return val && typeof val == 'string' && val !== nf;
}
function hasSpecialSuffix(model) {
var specials = [
'ANTIONE',
'ARNAUD',
'ASARO',
'BEALEY',
'BLYTHE',
'BOWEN',
'CABARITA',
'CAVENDISH',
'ENZA',
'GALION',
'KUROW',
'LEITH',
'LUCEA',
'LYVIA',
'MARQUIS',
'NARIVA',
'RENARD',
'RIGAUD',
'VOLET'
];
return {
hasSpecial:specials.indexOf(model) !== -1,
sku: (model == 'GALION' || model == 'CAVENDISH') ? 'SXLWXX' : 'SXCWXX'
};
}
function getModelPriceCode(code) {
var map = {
"ALEXANDRIA": "A",
"ALLURE": "A",
"ANTIONE": "AT",
"AQUARIUS": "A",
"ARNAUD": "AN",
"ASARO": "AS",
"BEALEY": "BL",
"BLYTHE": "BH",
"BOWEN": "BW",
"BREEZE": "B",
"CABARITA": "CB",
"CARESSE": "C",
"CASCADE": "C",
"CAVENDISH": "CD",
"CHARLESTON": "C",
"ECLIPSE": "E",
"EMBRACE": "A", // ????
"ENZA": "EN",
"EROS": "E",
"GALION": "GN",
"GULF": "G",
"INDULGENCE": "I",
"INFINITY": "I",
"KUROW": "KW",
"LEITH": "LH",
"LUCEA": "LC",
"LYVIA": "LY", // ????
"MARQUIS": "MQ",
"MIRAGE": "M",
"NARIVA": "NR",
"NEPTUNE": "N",
"PETITE": "P",
"POLARIS": "P",
"REEF": "R",
"RENARD": "RN",
"RIGAUD": "GD",
"ROYALE": "R",
"SOHO": "SH",
"SUBLIME": "S",
"SUISSE": "S",
"VALLEY": "VY",
"VENETIAN": "VN",
"VENUS": "V",
"VOGUE": "V",
"VOLET": "OE", // ????
"WHISPER": "W",
"ZEPHER": "Z"
};
return map[code] || code.charAt(0).toUpperCase();
}
})(); |
Custom SCPQ-Operation Form |
17 |
|
F |
12 |
2/4/2019 1:32 pm |
Build SKU |
|
|
Tom Unterfenger |
5 |
true |
CPQ_00010 Atlantis |
10 |
49 |
|
|
*/* |
F |
F |
val_84198_3701406_186 |
1 |
customrecord_scpq_operation |
|
rectype=49&e=T&id=12 |
12 |
Build SKU |
|
5 |
SCPQ-Action |
|
customrecordentry |
49 |
F |
custrecordentry |
20 |
| 13 |
|
|
|
|
|
PRICING |
var sku = getValue('OUTPUT', 'SKU');
var pricingData = loadListKeyValue('TUB_PRICING');
var prices = pricingData.filter(function (prc) {
return prc.PN == sku;
});
reset('PRICING');
reset('SPECS');
if (prices.length) {
prices = prices[0];
setValue('PRICING', 'COST', prices.COST);
setValue('PRICING', 'MAP', prices.MAP);
setValue('PRICING', 'MSRP', prices.MSRP);
setValue('PRICING', 'SELL', +prices.COST / 0.75);
// -- set the specifications
setValue('SPECS', 'NAME', prices.NAME);
setValue('SPECS', 'WEIGHT', prices.WEIGHT);
setValue('SPECS', 'HEIGHT', prices.HEIGHT);
setValue('SPECS', 'WIDTH', prices.WIDTH);
setValue('SPECS', 'SOAK_DEPTH', prices.SOAK_DEPTH);
setValue('SPECS', 'DIMENSIONS', prices.DIMENSIONS);
setValue('SPECS', 'LEAD_TIME', prices.LEAD_TIME);
setValue('SPECS', 'DEPTH', prices.DEPTH);
} else {
setValue('PRICING','NO_PRICE', sku);
} |
Custom SCPQ-Operation Form |
17 |
|
F |
13 |
3/28/2019 1:18 pm |
Pricing |
|
|
Tom Unterfenger |
5 |
(__["OUTPUT/SKU"]) |
CPQ_00010 Atlantis |
10 |
49 |
|
|
OUTPUT/SKU |
F |
F |
val_84242_3701406_586 |
100 |
customrecord_scpq_operation |
|
rectype=49&e=T&id=13 |
13 |
Pricing |
|
5 |
SCPQ-Action |
|
customrecordentry |
49 |
F |
custrecordentry |
4 |
| 14 |
|
|
|
|
|
DRAWING_URL |
window.cpiImages = window.cpiImages || function () {
var hasLoaded = false;
var imgMap = {};
var searchData = {
type : 'file',
filter : ['folder', 'is', '1336'],
fields : ['name', 'url', 'fileType']
};
function findImage() {
var imgSku = getValue('OUTPUT', 'IMG_SKU');
reset('OUTPUT', 'IMG_URL');
var imgUrl = '';
if (imgSku) {
imgUrl = cpiImages.getImageUrl(imgSku);
if (imgUrl) {
setValue('OUTPUT', 'IMG_URL', imgUrl);
} else {
console.warn('Could not find image url for', imgSku);
}
}
}
getData(searchData).done(function (imgs) {
hasLoaded = true;
if (imgs && imgs.length) {
imgs.forEach(function (img) {
var url = img.url;
var name = img.name;
imgMap[name] = url;
});
findImage();
scopeRefresh();
}
});
return {
getImageUrl : function (sku) {
var ret = '';
if (this.isReady() && (sku in imgMap)) {
ret = imgMap[sku];
}
return ret;
},
isReady : function () {
return hasLoaded;
},
findImg: function () {
return findImage();
}
}
}
();
window.cpiImages.findImg(); |
Custom SCPQ-Operation Form |
17 |
|
F |
14 |
12/18/2018 2:19 pm |
Drawing URL |
|
|
Tom Unterfenger |
5 |
true |
CPQ_00010 Atlantis |
10 |
49 |
|
|
*/* |
F |
F |
val_84539_3701406_205 |
3 |
customrecord_scpq_operation |
|
rectype=49&e=T&id=14 |
14 |
Drawing URL |
|
5 |
SCPQ-Action |
|
customrecordentry |
49 |
F |
custrecordentry |
3 |
| 16 |
|
|
|
|
|
BOM |
/**
*
* Description: Pulls item record for assembly from NS to get associated
* BOM components. If any add-ons are selected, they are appended to
* the base BOM
*
* For Meditub skus, there needs to be a "T" or "MT" used for the prefix.
*
**/
window.nsItemCache = window.nsItemCache || (function () {
var items = {};
return {
set: function (pn, data) {
items[pn] = [data];
},
get: function (pn) {
return items[pn] || null;
},
view: function () {
console.log(items);
}
};
})();
var sku = getValue('OUTPUT', 'BASE_SKU');
var searchObj = getSearchObj(sku);
searchItems(searchObj, setBOMItems, resetBomFields);
function getSearchObj(sku) {
var res = {};
var filter = [];
filter.push(['displayname', 'is', 'MT' + sku]);
filter.push('or');
filter.push(['displayname', 'is', 'T' + sku]);
res.async = false;
res.type = 'assemblyitem';
res.fields = ['displayname', 'internalid', 'description'];
res.loadapi = true;
res.sublists = {
'member': ['quantity', 'item_display', 'memberdescr', 'itemsource']
};
res.filter = filter;
return res;
}
function setBOMItems(items) {
// console.log('Found items', items);
var qTable = getQTable('BOM');
items.forEach(function (itm) {
nsItemCache.set(sku, itm);
var bom = itm.sublists.member;
if (bom.length) {
console.log('Found', bom.length, 'BOM items');
qTable.setRowCount(bom.length);
bom.forEach(function (cmpt, i) {
var idx = i + 1;
qTable.set('DESC', idx, cmpt.memberdescr);
qTable.set('ITEM', idx, cmpt.item_display);
qTable.set('SOURCE', idx, cmpt.itemsource);
qTable.set('QUANTITY', idx, cmpt.quantity);
});
}
});
}
function resetBomFields() {
var qTable = getQTable('BOM');
qTable.clear();
qTable.setRowCount(1);
}
function searchItems(filter, success, fail) {
if (nsItemCache.get(sku)) {
console.warn('From cache', sku);
return success(nsItemCache.get(sku));
}
getData(filter).done(function (res) {
if (res.length) {
success(res);
} else {
fail();
}
});
} |
Custom SCPQ-Operation Form |
17 |
|
F |
16 |
12/19/2018 2:50 pm |
BOM Evaluation |
|
|
Tom Unterfenger |
5 |
true |
CPQ_00011 Meditub |
11 |
49 |
|
|
*/* |
F |
F |
val_94889_3701406_554 |
101 |
customrecord_scpq_operation |
|
rectype=49&e=T&id=16 |
16 |
BOM Evaluation |
|
5 |
SCPQ-Action |
|
customrecordentry |
49 |
F |
custrecordentry |
9 |
| 17 |
|
|
|
|
|
BOM |
/**
*
* Description: Pulls item record for assembly from NS to get associated
* BOM components. If any add-ons are selected, they are appended to
* the base BOM
*
* For Atlantis skus, there needs to be a "T" used for the prefix.
*
**/
window.nsItemCache = window.nsItemCache || (function () {
var items = {};
return {
set: function (pn, data) {
items[pn] = [data];
},
get: function (pn) {
return items[pn] || null;
},
view: function () {
console.log(items);
}
};
})();
var sku = getValue('OUTPUT', 'SKU');
var searchObj = getSearchObj(sku);
searchItems(searchObj, setBOMItems, resetBomFields);
function getSearchObj(sku) {
var res = {};
var filter = ['displayname', 'is', 'T' + sku];
res.async = false;
res.type = 'assemblyitem';
res.fields = ['displayname', 'internalid', 'description'];
res.loadapi = true;
res.sublists = {
'member': ['quantity', 'item_display', 'memberdescr', 'itemsource']
};
res.filter = filter;
return res;
}
function setBOMItems(items) {
var qTable = getQTable('BOM');
items.forEach(function (itm) {
nsItemCache.set(sku, itm);
var bom = itm.sublists.member;
if (bom.length) {
console.log('Found', bom.length, 'BOM items');
qTable.setRowCount(bom.length);
bom.forEach(function (cmpt, i) {
var idx = i + 1;
qTable.set('DESC', idx, cmpt.memberdescr);
qTable.set('ITEM', idx, cmpt.item_display);
qTable.set('SOURCE', idx, cmpt.itemsource);
qTable.set('QUANTITY', idx, cmpt.quantity);
});
}
});
}
function resetBomFields() {
var qTable = getQTable('BOM');
qTable.clear();
qTable.setRowCount(1);
}
function searchItems(filter, success, fail) {
if (nsItemCache.get(sku)) {
console.warn('From cache', sku);
return success(nsItemCache.get(sku));
}
getData(filter).done(function (res) {
if (res.length) {
success(res);
} else {
fail();
}
});
} |
Custom SCPQ-Operation Form |
17 |
|
F |
17 |
3/28/2019 1:18 pm |
BOM Evaluation |
|
|
Tom Unterfenger |
5 |
true |
CPQ_00010 Atlantis |
10 |
49 |
|
|
*/* |
F |
F |
val_95139_3701406_316 |
102 |
customrecord_scpq_operation |
|
rectype=49&e=T&id=17 |
17 |
BOM Evaluation |
|
5 |
SCPQ-Action |
|
customrecordentry |
49 |
F |
custrecordentry |
3 |