From 40220177fa931162859cc27f49f9a96b74c76186 Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Sun, 28 Jan 2024 15:38:49 +0200 Subject: [PATCH 1/3] a.m. sales origin object added to Upsert JSON --- src/FileCabinet/SuiteScripts/lib/customscript_ext_util.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/FileCabinet/SuiteScripts/lib/customscript_ext_util.js b/src/FileCabinet/SuiteScripts/lib/customscript_ext_util.js index 717cf2f..22ec8b9 100644 --- a/src/FileCabinet/SuiteScripts/lib/customscript_ext_util.js +++ b/src/FileCabinet/SuiteScripts/lib/customscript_ext_util.js @@ -466,6 +466,11 @@ define([ } }, + 'saleOrigin': { + 'integratorId': 'NetSuite', + 'channel': 'NetSuite', + 'platform': 'NetSuite' + }, 'storeId': objExtendConfig.storeId, 'lineItems': objValues.lineItems, 'total': parseInt(objValues.total_amount * 100), From d1996c3e45dea9d416c46dcb5b84476cbdd1999d Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Fri, 16 Feb 2024 16:14:00 +0200 Subject: [PATCH 2/3] ue suitelet button --- ...customscript_ext_offer_modal_controller.js | 7 +++++- ...customscript_ext_so_offer_controller_cs.js | 24 ++++++++++++------- .../lib/customscript_ext_config_lib.js | 22 +++++++---------- .../customscript_ext_offer_modal_sl.js | 14 +++++++---- 4 files changed, 38 insertions(+), 29 deletions(-) diff --git a/src/FileCabinet/SuiteScripts/client/customscript_ext_offer_modal_controller.js b/src/FileCabinet/SuiteScripts/client/customscript_ext_offer_modal_controller.js index 7eb9ee1..9f617a4 100644 --- a/src/FileCabinet/SuiteScripts/client/customscript_ext_offer_modal_controller.js +++ b/src/FileCabinet/SuiteScripts/client/customscript_ext_offer_modal_controller.js @@ -89,10 +89,13 @@ define(['N/url', console.log('stItemId', stItemId); var stItemName = objCurrentRec.getText({ fieldId: 'custpage_item_select' }); var stItemList = objCurrentRec.getValue({ fieldId: 'custpage_item_list' }); + var stConfigRec = objCurrentRec.getValue({ fieldId: 'custpage_config' }); + var stLeadToken = objCurrentRec.getValue({ fieldId: 'custpage_lead_input' }); var stItemQty; var stLineNum; var stItemRefId; + if (!EXTEND_UTIL.objectIsEmpty(stItemId)) { var arrItemList = JSON.parse(stItemList); //var stItemQty = arrItemList.find(x => x.id === stItemId).quantity; @@ -111,7 +114,9 @@ define(['N/url', 'arrItemid': stItemList, 'line': stLineNum, 'quantity': stItemQty, - 'refid': stItemRefId + 'refid': stItemRefId, + 'config': stConfigRec, + 'leadToken': stLeadToken } }); diff --git a/src/FileCabinet/SuiteScripts/client/customscript_ext_so_offer_controller_cs.js b/src/FileCabinet/SuiteScripts/client/customscript_ext_so_offer_controller_cs.js index 8acd4a2..2dbf525 100644 --- a/src/FileCabinet/SuiteScripts/client/customscript_ext_so_offer_controller_cs.js +++ b/src/FileCabinet/SuiteScripts/client/customscript_ext_so_offer_controller_cs.js @@ -46,8 +46,9 @@ define([ console.log('Handling Input', context); // console.log('Sublist', context.currentRecord.getCurrentSublistValue({ sublistId: context.sublistId })); + var stExtendConfigRecId = runtime.getCurrentScript().getParameter('custscript_ext_config_rec_cs'); console.log('config', 'getting.....'); - var config = EXTEND_CONFIG.getConfig(1); + var config = EXTEND_CONFIG.getConfig(stExtendConfigRecId); console.log('config', config); var refIdValue = config.refId; @@ -138,7 +139,7 @@ define([ arrItemList = JSON.stringify(arrItemList); console.log('arrItemList', arrItemList); - _callSuitelet(arrItemList, stItemId, stItemName, stLineNum, intQty, stItemRefId, JSON.stringify(config)); + _callSuitelet(arrItemList, stItemId, stItemName, stLineNum, intQty, stItemRefId, stExtendConfigRecId); return true; } @@ -155,7 +156,8 @@ define([ }); console.log('linecount', linecount); console.log('config', 'getting.....'); - var config = EXTEND_CONFIG.getConfig(1); + var stExtendConfigRecId = runtime.getCurrentScript().getParameter('custscript_ext_config_rec_cs'); + var config = EXTEND_CONFIG.getConfig(stExtendConfigRecId); console.log('config', config); var refIdValue = config.refId; @@ -183,14 +185,15 @@ define([ line: i }); // Lookup to item to see if it is eligible for warranty offers + /* var arrItemLookupField = search.lookupFields({ type: 'item', id: stItemId, columns: 'custitem_product_protection_item' }); - var bIsWarranty = arrItemLookupField.custitem_ext_is_warrantable; - - log.debug('Is warranty', typeof(bIsWarranty) + ', ' + bIsWarranty); + // var bIsWarranty = arrItemLookupField.custitem_ext_is_warrantable; +*/ + // log.debug('Is warranty', typeof(bIsWarranty) + ', ' + bIsWarranty); if (refIdValue) { // Lookup to item to see if it is eligible for warranty offers var arrItemLookup = search.lookupFields({ @@ -228,16 +231,17 @@ define([ //console.log('objItem', objItem); //push to array // If item is not a warranty item, return - if (stExtendItem != stItemId || !bIsWarranty) { + if (stExtendItem != stItemId) { arrItemList.push(objItem); } } var stArrayItemList = JSON.stringify(arrItemList); console.log('stArrayItemList', stArrayItemList); - _callSuitelet(stArrayItemList, arrItemList[0].id, arrItemList[0].name, arrItemList[0].line, arrItemList[0].qty, arrItemList[0].refId); + _callSuitelet(stArrayItemList, arrItemList[0].id, arrItemList[0].name, arrItemList[0].line, arrItemList[0].qty, arrItemList[0].refId, stExtendConfigRecId); } function _callSuitelet(arrItemList, stItemId, stItemName, stLineNum, stItemQty, stItemRefId, config) { + console.log('config', config); //Resolve suitelet URL var slUrl = url.resolveScript({ scriptId: 'customscript_ext_offer_presentation_sl', @@ -249,9 +253,11 @@ define([ 'line': stLineNum, 'quantity': stItemQty, 'refid': stItemRefId, - 'config' : config + 'config' : config, + // 'leadToken': stLeadToken } }); + console.log('slUrl', slUrl); //Call the pop up suitelet window.open(slUrl, '_blank', 'screenX=300,screenY=300,width=900,height=500,titlebar=0,status=no,menubar=no,resizable=0,scrollbars=0'); diff --git a/src/FileCabinet/SuiteScripts/lib/customscript_ext_config_lib.js b/src/FileCabinet/SuiteScripts/lib/customscript_ext_config_lib.js index 191f711..3143902 100644 --- a/src/FileCabinet/SuiteScripts/lib/customscript_ext_config_lib.js +++ b/src/FileCabinet/SuiteScripts/lib/customscript_ext_config_lib.js @@ -12,7 +12,7 @@ define([ SANDBOX: 1, PRODUCTION: 2 } - exports.getConfig = function () { + exports.getConfig = function (stExtendConfigRecId) { //Get storeId & APIkey from config custom record var STORE_ID; @@ -25,20 +25,15 @@ define([ var SHIPPING_ITEM; var DOMAIN = 'https://api-demo.helloextend.com'; - // VF need to account for calling from Client and MR Scripts - var currScript= runtime.getCurrentScript(); - var stExtendConfigRecId - if(currScript.id == "customscript_ext_so_offer_controller_cs" ){ - stExtendConfigRecId = currScript.getParameter('custscript_ext_config_rec_cs'); - }else if(currScript.id == "customscript_ext_refund_create_mr" ){ - stExtendConfigRecId = currScript.getParameter('custscript_ext_config_record'); - }else{ - stExtendConfigRecId = currScript.getParameter('custscript_ext_config_rec'); + if(!stExtendConfigRecId){ + stExtendConfigRecId = runtime.getCurrentScript().getParameter('custscript_ext_configuration_record'); + log.audit('stExtendConfigRecId', stExtendConfigRecId); } + var arrFilters = []; log.debug('_getConfig: stExtendConfigRecId ', stExtendConfigRecId); - - var arrFilters = ["internalId", "is", stExtendConfigRecId]; - + if(stExtendConfigRecId){ + arrFilters.push(["internalId", "is", stExtendConfigRecId]); + } var customrecord_ext_configurationSearchObj = search.create({ type: "customrecord_ext_configuration", filters: [ @@ -72,7 +67,6 @@ define([ default: DOMAIN = 'https://api-demo.helloextend.com' }; - log.debug('_getConfig: DOMAIN ', DOMAIN); STORE_ID = result.getValue({ name: 'custrecord_ext_store_id' }); API_KEY = result.getValue({ name: 'custrecord_ext_api_key' }); EMAIL = result.getValue({ name: 'custrecord_ext_demo_email' }); diff --git a/src/FileCabinet/SuiteScripts/suitelet/customscript_ext_offer_modal_sl.js b/src/FileCabinet/SuiteScripts/suitelet/customscript_ext_offer_modal_sl.js index ae9a75f..f9b87e2 100644 --- a/src/FileCabinet/SuiteScripts/suitelet/customscript_ext_offer_modal_sl.js +++ b/src/FileCabinet/SuiteScripts/suitelet/customscript_ext_offer_modal_sl.js @@ -165,10 +165,11 @@ define([ var stItemInternalId = context.request.parameters.itemid; var stItemRefId = context.request.parameters.refid; var stLeadToken = context.request.parameters.leadToken; - var config = JSON.parse(context.request.parameters.config); + var stConfigRec = JSON.parse(context.request.parameters.config); + var objConfig = EXTEND_CONFIG.getConfig(stConfigRec); log.debug('stItemRefId', stItemRefId); log.debug('stLeadToken', stLeadToken); - log.debug('config ' + typeof config, config); + log.debug('objConfig ' + typeof objConfig, objConfig); // Create the form @@ -376,10 +377,10 @@ define([ if (stItemRefId || stLeadToken) { try { if(stLeadToken){ - var objResponse = EXTEND_API.getLeadOffers(stLeadToken, config); + var objResponse = EXTEND_API.getLeadOffers(stLeadToken, objConfig); log.debug('OFFER MODAL SUITELET: Offers JSON Response', objResponse); }else{ - var objResponse = EXTEND_API.getOffers(stItemRefId, config); + var objResponse = EXTEND_API.getOffers(stItemRefId, objConfig); log.debug('OFFER MODAL SUITELET: Offers JSON Response', objResponse); } @@ -392,8 +393,11 @@ define([ log.debug('OFFER MODAL SUITELET: arrPlans', arrPlans); if (!arrPlans) { var arrPlans = objResponseBody.plans.base; + if(!arrPlans){ + ///show alert no plans for item + } } - + //Populate Sublist Values for (var i = 0; i < arrPlans.length; i++) { objPlanList.setSublistValue({ From 284837844645af15c3533585e6deff2d393a0525 Mon Sep 17 00:00:00 2001 From: amillerExtend <85582815+amillerExtend@users.noreply.github.com> Date: Fri, 23 Feb 2024 10:37:25 +0200 Subject: [PATCH 3/3] ref id util --- src/FileCabinet/SuiteScripts/lib/customscript_ext_util.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/FileCabinet/SuiteScripts/lib/customscript_ext_util.js b/src/FileCabinet/SuiteScripts/lib/customscript_ext_util.js index 717cf2f..18a9a1d 100644 --- a/src/FileCabinet/SuiteScripts/lib/customscript_ext_util.js +++ b/src/FileCabinet/SuiteScripts/lib/customscript_ext_util.js @@ -538,6 +538,7 @@ define([ return objAddress; }; //get Item's reference ID + exports.getItemRefId = function (stItemId, objExtendConfig) { // var config = EXTEND_CONFIG.getConfig(); var refIdValue = objExtendConfig.refId;