diff --git a/.DS_Store b/.DS_Store new file mode 100644 index 0000000..9f775f2 Binary files /dev/null and b/.DS_Store differ diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9bea433 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ + +.DS_Store diff --git a/SuiteScripts/.DS_Store b/SuiteScripts/.DS_Store index a65137c..4c5e4f0 100644 Binary files a/SuiteScripts/.DS_Store and b/SuiteScripts/.DS_Store differ diff --git a/SuiteScripts/Client_SS2_ProjOps.js b/SuiteScripts/Client_SS2_ProjOps.js deleted file mode 100644 index f16d53c..0000000 --- a/SuiteScripts/Client_SS2_ProjOps.js +++ /dev/null @@ -1,104 +0,0 @@ -/******************************************************************* -* -* -* Name: Client ProjOps -* Script Type: Client Script -* Version: 1.0.0 -* -* -* Author: pj92isngh -* Prabhjit Singh - -* Purpose: -* client script works on native project record and custom record -* it will pull the related ProjOp record and gets its value -* This value can be used for various purposes (show on PDF/employee record etc) - -* -* -* ******************************************************************* */ - - -/** - * @NApiVersion 2.x - *@NScriptType ClientScript - * - */ -define(['N/error', 'N/currentRecord', 'N/record', 'N/runtime', 'N/log'], - //customer script to test ProjOps - //accquire the title - //runs in edit mode - function (error, currentRecord, record, runtime, log) { - function pageInit(context){ - log.debug({ - title: 'DEBUG', - details: '>>StarCLIENTScript<<' - }); - var currentScript = runtime.getCurrentScript(); - var myScriptParameter = currentScript.getParameter({ - name : "pi" - }); - log.debug({ - title: 'DEBUG', - details: '*custscript_paramter* '+myScriptParameter - }); - //get params - //checking another paramter here for logging purpose - /* var recID_p = context.request.parameters.pr; - log.debug({ - title: 'DEBUG', - details: '*recID params* '+recID_p - }); - //get all params - var params = JSON.stringify(context.request.parameters); - log.debug({ - title: 'DEBUG', - details: '*params '+params - }); - - */ - //if(context == 'view' || context == 'edit'){ - var currentRec = context.currentRecord; - var projOppRec_id = currentRec.id; - var projOppRec_type = currentRec.type; - - - log.debug({ - title: 'DEBUG', - details: '*prjOps ID* '+projOppRec_id - }); - log.debug({ - title: 'DEBUG', - details: '*prjOps type* '+projOppRec_type - }); - - - //load the relaated record - //get the title from it - var ProjOppRec = record.load({ - type: 'customrecord166', - id: projOppRec_id - }); - - log.debug({ - title: 'DEBUG', - details: '>>PROJOpp Rec NAME<: ' +ProjOppRec.getValue({ - fieldId: 'name' - }) - }); - - - var Proj_name = ProjOppRec.getValue({ - fieldId: 'name' - }); - log.debug({ - title: 'DEBUG', - details: '>>Proj_name Rec<: ' +Proj_name - }); - - } - - return{ - pageInit: pageInit - } - }); diff --git a/SuiteScripts/Client_SS2_dialogTest.js b/SuiteScripts/Client_SS2_dialogTest.js deleted file mode 100644 index fe3e709..0000000 --- a/SuiteScripts/Client_SS2_dialogTest.js +++ /dev/null @@ -1,70 +0,0 @@ -/******************************************************************* -* -* -* Name: Client_SS2_dialogTest.js -* Script Type: Client Script -* Version: 1.0.0 -* -* -* Author: Prabhjit Singh -* Purpose: CLIENT script testing on custom Serial Num record. -* Code is only used for testing dialogs/alerts on the custom record type -* -* ******************************************************************* */ -/** - * @NApiVersion 2.x - *@NScriptType ClientScript - * - */ -define(['N/ui/message', 'N/ui/dialog'], - function(message, dialog){ - function showAlert(){ - log.debug({title: 'DEBUG', details: '>>client start<<'}); - try{ - //confirmation message test - var myMsg = message.create({ - title: "My Title", - message: "My Message", - type: message.Type.CONFIRMATION - }); - // will disappear after 5s - myMsg.show({duration: 5000}); - }catch(error1){ - log.debug({title: 'DEBUG', details: 'catch 1 error1: ' +error1}); - } - try{ - //testing message information - var myMsg2 = message.create({ - title: "My Title 2", - message: "My Message 2", - type: message.Type.INFORMATION - }); - - myMsg2.show(); - setTimeout(myMsg2.hide, 15000); // will disappear after 15s - }catch(error2){ - log.debug({title: 'DEBUG', details: 'catch 2 error2: ' +error2}); - } - try{ - var myMsg3 = message.create({ - title: "My Title 3", - message: "My Message 3", - type: message.Type.WARNING - }); - myMsg3.show(); // will stay up until hide is called. - }catch(error3){ - log.debug({title: 'DEBUG', details: 'catch 3 error3: ' +error3}); - } - - //alert------------------------------- - dialog.alert({ - title: 'Alert', - message: 'Use only for custom scripts, Click OK to continue.' - }); - //alert--end-------------------------- - log.debug({title: 'DEBUG', details: '>>client END<<'}); - } - return{ - pageInit: showAlert - } -}); diff --git a/SuiteScripts/Client_SS2_search_2_extractJSON.js b/SuiteScripts/Client_SS2_search_2_extractJSON.js deleted file mode 100644 index 4f217e0..0000000 --- a/SuiteScripts/Client_SS2_search_2_extractJSON.js +++ /dev/null @@ -1,94 +0,0 @@ -/******************************************************************* -* -* -* Name: Client_SS2_search_2_extractJSON.js -* Script Type: ClientScript -* Version: 0.0.1 -* -* -* Author: PJ92Singh -* Prabhjit singh -* -* Purpose: testing search and forEach function -* to get results and log them -* -* added GROUP search results and testing getting the results via JSON extraction -* this way this info can be used for other purposes -* -* ******************************************************************* */ -/** -* @NApiVersion 2.x -*@NScriptType ClientScript -* -*/ -/*1st test with the search and the information it returns - */ -require(['N/search'], - function(search){ - var mysearch = search.load({ id: 'customsearch98'}); - console.log({ title: 'DEBUG', details: 'search details: ' + mysearch +' JSON: ' +JSON.stringify(mysearch)}); - console.log({ title: 'DEBUG', details: 'run search' }); - var mycolumns = mysearch.columns; - console.log({title: 'DEBUG', details: 'mycolumns: '+mycolumns}); - var resultSet = mysearch.run(); - console.log('column numbers: ' +resultSet.columns.length); - resultSet.columns.forEach(function(col){ - console.log('col ' + col); - }); - var results1 = resultSet.each(function (result) { - var entity = result.getValue({ - name: 'name' - }); - console.log({ title: 'DEBUG', details: 'entity : ' + entity }); - var custrecord13 = result.getValue({ - name: 'custrecordcust_vehicle_make_1' - }); - console.log({ title: 'DEBUG', details: 'custrecord13 : ' + custrecord13 }); - return true; - }); - console.log({ title: 'DEBUG', details: 'results: ' + results1 + 'JSON: ' + JSON.stringify(results1) }); -}); - -/***************************** - * 2nd - *testing full json data return - * also extraction of the data for - * storage and later usage - */ -require(['N/record', 'N/search'], -function(record, search) { - var avgLeadTimeSearch = search.load({ - id : 'customsearch98' - }); - avgLeadTimeSearch.run().each(function(result){ // log each column - console.log("Search Column (group): "+ JSON.stringify(result)); - var z = JSON.stringify(result); - console.log('z **: ' +z); - var obj = JSON.parse(z); - console.log('obj: ' +JSON.stringify(obj)); - //extract data from JSON value and group arrays - var values1 = obj.values; - console.log('values1 **: ' +values1 +' stringify: ' +JSON.stringify(values1)); - var hh = JSON.stringify(values1); - console.log('hh: '+hh); - //for loop for split - var hhL = hh.length; - console.log('hhL: ' +hhL); - var col_count = 0; - for(var i=0; i < hhL; i++){ - //split - - if(hh[i] == ":"){ - col_count++; - } - } - console.log('col_count: ' +col_count); - if(col_count != 0){ - var zz = hh.split(":", 2); - console.log('zz[0]: ' +zz[0] +' zz[1]: ' +zz[1]); - } - - - return true; - }); -}); diff --git a/SuiteScripts/Client_SS2_vendorBill_copyContext.js b/SuiteScripts/Client_SS2_vendorBill_copyContext.js deleted file mode 100644 index 776344c..0000000 --- a/SuiteScripts/Client_SS2_vendorBill_copyContext.js +++ /dev/null @@ -1,54 +0,0 @@ -/******************************************************************* -* -* -* Name: Client_SS2_vendorBill_copyContext.js -* Script Type: ClientScript -* Version: 0.0.1 -* -* -* Author: Prabhjit Singh -* pj92singh -* Purpose: Inactive Vendor > Make Copy of Vendor Bill > Show warning message -* -* script runs on vednor bills/payment -* **** if bill is not stand alone then the system treats it as a copy -* so the script will execute in that context as well **** -* ******************************************************************* */ - /** - * @NApiVersion 2.x - *@NScriptType ClientScript - * - */ - define(['N/record', 'N/currentRecord', 'N/ui/message', 'N/ui/dialog'], - function(record, currentRecord, message, dialog){ - function pageInit(context){ - log.debug({title: 'DEBUG', details: 'CLIENT SS2' +'context ' +context +'JSON ' +JSON.stringify(context)}); - if(context.mode == 'create'){ - //get record?!?! - // - //new record - var recID = record.id; - var recType = record.type; - log.debug({title: 'DEBUG', details: 'id//type: ' +recID +' // ' +recType}); - //alert------------------------------- - dialog.alert({ - title: 'Alert', - message: 'being made originally!' - }); - } - //in copy mode!!! - if(context.mode =='copy'){ - log.debug({title: 'DEBUG', details: 'copy mode'}); - //alert------------------------------- - dialog.alert({ - title: 'Alert', - message: 'being made in copy!' - }); - //alert--end-------------------------- - } - } - return{ - pageInit: pageInit - - } - }); \ No newline at end of file diff --git a/SuiteScripts/Client_checkbox.js b/SuiteScripts/Client_checkbox.js deleted file mode 100644 index a3aaa96..0000000 --- a/SuiteScripts/Client_checkbox.js +++ /dev/null @@ -1,230 +0,0 @@ -/******************************************************************* -* -* -* Name: Client Checbox checker -* Script Type: Client Script -* Version: 1.0.0 -* -* -* Author: pj92singh -Prabhjit Singh - -* Purpose: This script checks value of custom field (checkbox type) -* Then based on the value it will allow the access of the record -* else alert and lock the record -* -* ******************************************************************* */ - - -/** - * @NApiVersion 2.x - *@NScriptType ClientScript - * - */ -define(['N/currentRecord', 'N/search', 'N/runtime', 'N/ui/message'], - function(currentRecord, search, runtime, message){ - function checkBoxcheck(scriptcontext){ - //on the current record - //get the entity and check that entity - alert('start of checkboxx script'); - var crec = currentRecord.get(); - - - - //use lookupfield - try{ - if (custEntity != null){ - var custEntity = crec.getValue({ fieldId: 'entity'}); - //console - log.debug({ title: 'DEBUG', details: 'entity: ' +custEntity}); - //log it - try{ - var createdFromField = crec.getValue({ fieldId: 'createdfrom'}); - //console - log.debug({ title: 'DEBUG', details: 'createdfrom: ' +createdFromField}); - }catch(error){ - log.debug({title: 'DEBUG', details: 'createdfrom catch error'}); - } - var customerField = search.lookupFields({ - type: search.Type.CUSTOMER, - id: custEntity, - columns : [ 'custentity14'] - }); - /* - original - var customerField = search.lookupFields({ - type: search.Type.CUSTOMER, - id: custEntity, - columns : [ 'custentity14'] - }); - var checkboxx = customerField.custentity14; - */ - var checkboxx = customerField.custentity14.value; - - log.debug({ title: 'DEBUG', details: 'cheboxx status: ' +checkboxx}); - - //if option to create or not create the record - if(checkboxx == true){ - var envyType = runtime.envType; - var cType = runtime.ContextType; - - - //console - log.debug({ title: 'DEBUG', details: 'envType: ' +envyType +'cType: ' +cType}); - - //also check context - if(scriptcontext == 'CREATE' || scriptcontext == 'EDIT' || createdFromField == undefined || createdFromField != null){ - //let the create the invoice - - }else{ - //allowed - //console - log.debug({ title: 'DEBUG', details: 'cust: ' +custEntity +' allowed!'}); - } - - } - //elsee if the checkboxx is fals - //don't let them create the record - else if(checkboxx == false){ - if(scriptcontext == 'CREATE' && createdFromField == undefined){ - //console - log.debug({ title: 'DEBUG', details: 'cust: ' +custEntity +' allowed in condtion 2'}); - //allow only if stand alone invoice - }else{ - //don't let them create the record - //console - log.debug({ title: 'DEBUG', details: 'cust: ' +custEntity + ' condtion2 not allowed!'}); - var notAllowedMessage = message.create({ - title: "NOT ALLOWED", - message: "Customer: " +custEntity +' not allowed!!', - type: message.Type.WARNING - }); - - notAllowedMessage.show(); - } - - - } - }//end if custEntity != null - //endcatch - }catch(error){ - log.debug({ title: 'DEBUG', details: 'catch error!!!'}); - - } - - } - /* Validate field function - -check the script context & check what entity is being inputted - -depending on that you can warn/alert the user - -then not save the record - */ - function validateCustomer(scriptcontext, crec, custEntity, createdFromField){ - //also check the customer when field is changed - log.debug({ title: 'DEBUG', details: '>> fieldValidate function<< '}); - var validateContext = scriptcontext.fieldId; - log.debug({ title: 'DEBUG', details: '>> fieldValidate context ' +validateContext}); - - //var custEntity = crec.getValue({ fieldId: 'entity'}); - //if(scriptcontext.fieldId == 'entity'){ - try{ - //if (custEntity != null){ - - var crec = currentRecord.get(); - var custEntity = crec.getValue({ fieldId: 'entity'}); - var createdFromField = crec.getValue({ fieldId: 'createdfrom'}); - log.debug({ title: 'DEBUG', details: 'createdfrom in validate: ' +createdFromField}); - - var customerField = search.lookupFields({ - type: search.Type.CUSTOMER, - id: custEntity, - columns : [ 'custentity14'] - }); - var checkboxx = customerField.custentity14; - //var supervisor = customerField.supervisor[0].text; - //console - log.debug({ title: 'DEBUG', details: 'cheboxx status: ' +checkboxx}); - - //alert('chekbox: ' +email +'supervisor: ' +supervisor); - - - //if option to create or not create the record - if(checkboxx == true){ - var envyType = runtime.envType; - var cType = runtime.ContextType; - - - //console - log.debug({ title: 'DEBUG', details: 'envType: ' +envyType +'cType: ' +cType}); - - //also check context - if(scriptcontext == 'CREATE' || scriptcontext == 'EDIT' || createdFromField == undefined || createdFromField != null){ - //let the create the invoice - log.debug({ title: 'DEBUG', details: 'cust: ' +custEntity +' condtion 1 allowed!'}); - //alert - var allowedInfoMessage = message.create({ - title: "Allowed", - message: "Customer " +custEntity + " is allowed.", - type: message.Type.INFORMATION - }); - - allowedInfoMessage.show(); - setTimeout(allowedInfoMessage.hide, 10000); - - }else{ - //allowed - //console - log.debug({ title: 'DEBUG', details: 'cust: ' +custEntity +' condtion 1 not allowed!'}); - } - - } - //elsee if the checkboxx is fals - //don't let them create the record - else if(checkboxx == false){ - if(scriptcontext == 'CREATE' && createdFromField == undefined){ - //console - log.debug({ title: 'DEBUG', details: 'cust: ' +custEntity +' Allowed in condtion 2'}); - //allow only if stand alone invoice - }else{ - //don't let them create the record - //console - log.debug({ title: 'DEBUG', details: 'cust: ' +custEntity +' Not allowed in condtion 2 !'}); - - var notAllowedMessage = message.create({ - title: "NOT ALLOWED", - message: "Customer: " +custEntity +' not allowed!!', - type: message.Type.WARNING - }); - - notAllowedMessage.show(); - setTimeout(notAllowedMessage.hide, 10000); - - } - - } - //}//end if custEntity != null - //endcatch - }catch(error){ - log.debug({ title: 'DEBUG', details: 'catch error!!!'}); - - } - // }//end of main if - - - } - //save record function - function saveRecord(checkboxx, createdFromField){ - if(checkboxx == false || createdFromField == null){ - //cannot save record - return false; - }else if(checkboxx == true || createdFromField != null){ - return true; - } - } - //end of save record function - return{ - pageInit: checkBoxcheck, - validateField: validateCustomer, - saveRecord: saveRecord - } - -}); diff --git a/SuiteScripts/Client_jQuery_hide.js b/SuiteScripts/Client_jQuery_hide.js deleted file mode 100644 index f038745..0000000 --- a/SuiteScripts/Client_jQuery_hide.js +++ /dev/null @@ -1,35 +0,0 @@ -/******************************************************************* -*pj92singh -*Prabhjit Singh -* -* Name: Client Checbox checker -* Script Type: Client Script -* Version: 1.0.0 -* -* -* Author: pj92singh -Prabhjit Singh -* Purpose: SS1.0 This script usse external jQuery libray functions. -* In this case it will hide the expense sublist -* -* -* ******************************************************************* */ - -function pageLoadHideSublist(){ - - - var recID = nlapiGetRecordId(); - var recType = nlapiGetRecordType(); - nlapiLogExecution('DEBUG', 'recstuff', 'rectype ' +recType +'recID ' +recID); - - try{ - nlapiLoadRecord(type, id, initializeValues) - var POrec = nlapiLoadRecord(recType, recID); - nlapiLogExecution('DEBUG', 'begin hide', 'hiding using jQuery'); - //hide sublist - jQuery('#expenselnk').hide(); - - }catch(error){ - nlapiLogExecution('DEBUG', 'catch', '***catch error*** ' +JSON.stringify(error)); - } -} \ No newline at end of file diff --git a/SuiteScripts/MapReduce_SS2_myTest.js b/SuiteScripts/MapReduce_SS2_myTest.js deleted file mode 100644 index 6ae5dd2..0000000 --- a/SuiteScripts/MapReduce_SS2_myTest.js +++ /dev/null @@ -1,96 +0,0 @@ -/******************************************************************* -* -* -* Name: MapReduce_SS2_myTest.js -* Script Type: MapReduce Script -* Version: 0.0.2 -* -* -* Author: pj92singh -* Prabhjit Singh -* Purpose: testing map/reduce script -* running a serach and with the data set given we can manipulate records -* and process it efficiently using lookUp fields and SubmitFields -* -* -* ******************************************************************* */ -/** - * @NApiVersion 2.x - * @NScriptType MapReduceScript - */ - -define(['N/search', 'N/record'], - function (search, record) { - - function InputData() { - log.debug({ title: 'DEBUG', details: 'load search' }); - try { - //load bob search - var searchSO = search.load({ - id: 21 - }); - // var resultSet = searchSO.run(); - return searchSO; - } catch (error1) { - log.debug({ title: 'catch1', details: 'load search fail/run fail: ' + error1 }); - } - - } - //map function will take the data and - //preform a task - //map is triggered everytime for each key value pair it gets - //and set custom field on salesrecordtest - function map(context) { - log.debug({ title: 'DEBUG', details: 'map function' +' JSON context: ' +JSON.stringify(context)}); - //JSON map parse stuff - try { - var rec = context.value; - log.debug({ title: 'DEBUG', details: 'rec: ' + rec }); - var rec1 = JSON.parse(rec); - log.debug({ title: 'DEBUG', details: 'rec1: ' + rec1 }); - var recID = rec1.id; - var recType = rec1.recordType; - log.debug({ title: 'DEBUG', details: 'recID: ' +recID +' recType: ' +recType }); - - - //if rec and id are not empty set the custom field - if(rec1 != null || rec1 != 'undefiend'){ - if(recID != null && recType != null){ - var custRichText = search.lookupFields({ - type: search.Type.SALES_ORDER, - id: recID, - columns: ['custbody90'] - }); - - var custRichText1 = custRichText + ' :added through myTest M/R script: '; - - //submit custombody field - var id = record.submitFields({ - type: record.Type.SALES_ORDER, - id: recID, - values: { - custbody90: custRichText1 - }, - options: { - enableSourcing: false, - ignoreMandatoryFields : true - } - }); - } - } - } catch (error2) { - log.debug({ title: 'catch1', details: 'map fail: ' + error2 }); - } - } - //testing reduce function with the data set it gets - //invoked one time for each unique key - function reduce(context){ - log.debug({ title: 'DEBUG', details: 'reduce function' +' JSON context: ' +JSON.stringify(context)}); - - } - return { - getInputData: InputData, - map: map, - reduce: reduce - } - }); \ No newline at end of file diff --git a/SuiteScripts/SS2_MapReduce_search96.js b/SuiteScripts/SS2_MapReduce_search96.js deleted file mode 100644 index 34936e8..0000000 --- a/SuiteScripts/SS2_MapReduce_search96.js +++ /dev/null @@ -1,91 +0,0 @@ -/******************************************************************* -* -* -* Name: MapReudce search96 -* Script Type: Map Reduce Script -* Version: 1.0.0 -* -* -* Author: prabhjitsinghdev -Prabhjit Singh - -* Purpose: Map/reduce script example --referring to search parameter in test account --then retrive related fields and return appropriate data -* -* -* ******************************************************************* */ - -/** - *@NApiVersion 2.1 - *@NScriptType MapReduceScript - */ -//2nd map reduce for custom 15 saved serach -define(['N/search'], (search) => { - const getInputData = (context) => { - try { - const script = runtime.getCurrentScript(); - const params = { - search_id: script.getParameter('custscript_fbn_mr_ach_search'), - max_records: script.getParameter('custscript_fbn_mr_ach_max_records') - }; - log.debug({ title: 'DEBUG search', details: params.search_id }); - if (isEmpty(params.search_id)) { - log.error({ title: 'ERROR missing search', details: `Search is required.` }); - return; - } - const s = search.load({ - id: params.search_id - }); - - return s; - - } catch (e) { - log.error({ title: 'ERROR getInputData', details: e }); - } - } - const map = (context) => { - try { - //key stuff - var key = context.key; - var recobj = JSON.parse(context.value); //gettting object - var trandate = recobj.values.trandate; - var transactionnumber = recobj.values.transactionnumber; - var salesrepName = recobj.values.salesrep.text; - var salesrepID = recobj.values.salesrep.value; - var salesrepSupID = recobj.values['supervisor.salesRep'].value; - var salesrepSupName = recobj.values['supervisor.salesRep'].text; - log.debug({ - title: 'DEBUG', - details: 'rec obj: ' + recobj - }); - //now break that down more - var salesrep = recobj.values.salesrep; - //now try to get supevisor's id - //values.values.supervisor.text?? - var supervisorName = recobj.values.supervisor.text; - log.debug({ - title: 'DEBUG', - details: 'Supervisor Name: ' + supervisorName - }); - - context.write({ - key: salesrepID, - value: transactionnumber - }); - //update the memo of each SALES REP - //with this line - //the sales orders under your name are: " " - - } catch (e) { - log.error({ title: 'ERROR map', details: e }); - } - - - } - - return { - getInputData, - map - } -}); diff --git a/SuiteScripts/Suitelet_SS2_sourceHTML.js b/SuiteScripts/Suitelet_SS2_sourceHTML.js deleted file mode 100644 index c37b809..0000000 --- a/SuiteScripts/Suitelet_SS2_sourceHTML.js +++ /dev/null @@ -1,144 +0,0 @@ - /******************************************************************* -* -* -* Name: Suitelet_SS2_sourceHTML.js -* Script Type: Suitelet Script -* Version: 1.0.0 -* -* -* Author: Prabhjit Singh -* Purpose: Suitelet to pass html code in 2 methods -* 2 ways to deal with this -* 1) create FORM with INLINEHTML field that sources the -* file information as the deafult value -* 2) create everythign via HTML code including button -* using button tag -* -* -* ******************************************************************* */ - /** - * @NApiVersion 2.x - *@NScriptType Suitelet - * - */ -define(['N/runtime', 'N/file', 'N/ui/serverWidget', 'N/ui/dialog'], - function(runtime, file, ui, dialog){ - /* - testing SUITELET to pass html code - for case - 3258463 - How to pass data to HTML suitelet 37380 Advanced Cloud Solutions LLP - - -------*********************-------- - FINAL NOTES - 2 ways to deal with this - 1) create FORM with INLINEHTML field that sources the - file information as the deafult value - 2) create everythign via HTML code including button - -using button tag - ----**********************---------- - Oct 10th 2019, adding - var scriptObj2 = runtime.getCurrentScript(); -log.debug("Remaining governance units2 in mapp stage " + scriptObj2.getRemainingUsage()); - -this is for testing usage limit ------*************************---------- - - */ - - function post(context){ - // - var reponse = context.response; - var request = context.request; - var method = request.method; - //if(method == 'POST'){ - log.debug({ title: 'DEBUG', details: 'start' }); - var runInfo = runtime.getCurrentSession(); - // - log.debug({ title: 'DEBUG', details: 'runInfo ' +runInfo }); - //testing for suiteanswers as well - //ID: 30315 - var test_h1 = '

SUITELET running method 1


First name:



Last name:




'; - var test_h2_no_form = '

SUITELET running method 2


'; - //load the file - //and see if we can extract its contents - //also have form for butotn - try{ - //add a form for button - //2nd thing requested by custome - //cannot do both bc it needs writePage func - //so use the html button tage instead - - /* - var form = ui.createForm({ - title: 'Create HTML sourcing SUIETLET' - }); - //add button to form - form.addButton({ - id : 'custpage_options', - label : 'My Options', - functionName : 'options_fxn' - }); - */ - - //load file - var basicFile = file.load({ - id: 'SuiteScripts/basic_h.txt' - }); - log.debug({ title: 'DEBUG', details: 'basicFile ' +basicFile }); - var bfile_info = basicFile.getContents(); - //do inline html - // - /* - var bf_form = form.addField({ - id: 'custpage_bfile_info', - label: 'bfile_info', - type: ui.FieldType.INLINEHTML - }); - bf_form.defaultValue = bfile_info; - */ - /* Method used to pass the next line as an argument to a developer-defined function. You can call this method multiple times to loop over the file contents as a stream. - - Return false to stop the loop. Return true to continue the loop. By default, false is returned when the end of the file is reached. - - This method can be used on text or .csv files. - */ - log.debug({ title: 'DEBUG', details: 'bfile_info ' +bfile_info }); - - - //1st method - //writepage - //to create form with default inlinehtml field - //context.response.writePage(form); - /************************************** */ - //2nd method here - //using write and add the html code for button - //context.response.write(test_h2_no_form +bfile_info); - - //testing for suiteanswers - context.response.write(test_h1); - var scriptObj2 = runtime.getCurrentScript(); - log.debug({title: "DEBUG", details:"Remaining governance units " + scriptObj2.getRemainingUsage()}); - - }catch(error){ - log.debug({ title: 'error', details: 'error ' +error +' JSON error: ' +JSON.stringify(error) }); - } - //}//else method == post - //else if(method == 'POST'){ - log.debug({ title: 'else post', details: 'ELSE POST METHOD'}); - try{ - //get value - var fname_post = request.parameters.test_h1; - log.debug({ title: 'fname_post', details: 'fname_post: ' +fname_post}); - }catch(error2){ - log.debug({ title: 'error', details: 'error2 ' +error2 +' JSON error2: ' +JSON.stringify(error2) }); - } - //} - } - - - return{ - onRequest : post - } - -}); diff --git a/SuiteScripts/Suitelet_createMessage.js b/SuiteScripts/Suitelet_createMessage.js deleted file mode 100644 index 5f6b139..0000000 --- a/SuiteScripts/Suitelet_createMessage.js +++ /dev/null @@ -1,145 +0,0 @@ -/******************************************************************* -* -* -* Name: Suitelet create Message record -* Script Type: Suitelet Script -* Version: 1.0.0 -* -* -* Author: pj92singh - Prabhjit Singh - -* Purpose: SUITElet which creates a message record between employee and customer --the script will then redirect to the message record when created - -* -* -* ******************************************************************* */ -/** - * @NApiVersion 2.x - * @NScriptType suitelet -*/ -define(['N/record', 'N/ui/dialog', 'N/redirect'], function(record, ui, redirect){ - - /*making suitelet for testing message record - and setting the CC sublist values - */ - function onRequest(){ - log.debug({ - title: 'dEBUG', - details: '>>starting suitelet<<' - }); - var mesRec = record.create({ - type: record.Type.MESSAGE, - isDynamic: false - }); - //set values for the fields - mesRec.setValue({ - fieldId: 'authoremail', - value: 'testing1@netsuite.com' - }); - mesRec.setValue({ - fieldId: 'recipientemail', - value: 'testing2@netsuite.com' - }); - mesRec.setValue({ - fieldId: 'subject', - value: 'SS2.0 Suitelet Message' - }); - mesRec.setValue({ - fieldId: 'message', - value: 'test email made via 2.0 suitelet for case testing' - }); - //get sublist - - var ccsub_list = mesRec.getSublist({ - sublistId: 'ccbcclist ' - }); - log.debug({ - title: 'dEBUG', - details: 'sublist: ' +ccsub_list - }); - try{ - var lineNum = mesRec.selectNewLine({ - sublistId: 'ccbcclist' - }); - log.debug({ - title: 'dEBUG', - details: 'new line: ' +lineNum - }); - /* - mesRec.selectNewLine({ - sublistId: 'ccbcclist' - });*/ - mesRec.setCurrentSublistValue({ - sublistId: 'ccbcclist', - fieldId: 'cc', - value: false - }); - log.debug({ - title: 'dEBUG', - details: 'cc false' - }); - mesRec.setCurrentSublistValue({ - sublistId: 'ccbcclist', - fieldId: 'bcc', - value: true - }); - log.debug({ - title: 'dEBUG', - details: 'bcc true' - }); - mesRec.setCurrentSublistValue({ - sublistId: 'ccbcclist', - fieldId: 'email', - value: 'machan1@netsuite.com' - }); - log.debug({ - title: 'dEBUG', - details: 'mchan email' - }); - - mesRec.commitLine({ - sublistId: 'ccbcclist' - }); - log.debug({ - title: 'dEBUG', - details: 'end of setting all values' - }); - }catch(error){ - log.debug({ - title: 'DEBUG', - details: 'catch error' - }); - } - //submit record - var messREC_ID = mesRec.save(); - log.debug({ - title: 'DEBUG', - details: 'finished rec ID: ' +messREC_ID - }); - alert('message created' +messREC_ID); - - //---------------------------------- - //redirect code - log.debug({ - title: 'Debug', - details: 'redirect:start' - }); - redirect.toRecord({ - type : record.Type.MESSAGE, - id : messREC_ID - }); - log.debug({ - title: 'Debug', - details: 'redirect:end**' - }); - //end of redirect code - //----------------------------------------------- - } - return{ - onRequest: onRequest - } - - -}); diff --git a/SuiteScripts/Suitelet_trigger_workflow_SS1.js b/SuiteScripts/Suitelet_trigger_workflow_SS1.js deleted file mode 100644 index 985163e..0000000 --- a/SuiteScripts/Suitelet_trigger_workflow_SS1.js +++ /dev/null @@ -1,29 +0,0 @@ -/******************************************************************* -* -* -* Name: Suitelet_SS1_triggerWorkflow.js -* Script Type: Suitelet Script -* Version: 1.0.0 -* -* -* Author: Prabhjit Singh -* Purpose: tigger worflow4075 -* -* -* ******************************************************************* */ -//ss1.0 -//script used for running workflow -//SUITELET -function triggerTheWorkflow(scriptcontext){ - - nlapiLogExecution('DEBUG', 'start script', 'starting scrit//workflow should be running'); - nlapiTriggerWorkflow('purchaseorder', '4500', 'customworkflow130', 'workflowaction4075'); - //using the 'workflowaction4075' - //this action creates the button - //so this is what you reference to "trigger" the button click - var html = '

Suitelet RAN; check the Purchase order 4500

'; - response.write(html); - nlapiLogExecution('DEBUG', 'end script', 'ENDING script// workflow should be running'); - - nlapiSendEmail(author, recipient, subject, body, cc, bcc, records, attachments, notifySenderOnBounce, internalOnly, replyTo) -} \ No newline at end of file diff --git a/SuiteScripts/UE_SS2_Reprint_PDF.js b/SuiteScripts/UE_SS2_Reprint_PDF.js deleted file mode 100644 index 7b677fd..0000000 --- a/SuiteScripts/UE_SS2_Reprint_PDF.js +++ /dev/null @@ -1,112 +0,0 @@ -/******************************************************************* -* -* -* Name: UE_SS2_Reprint_PDF.js -* Script Type: UserEvent Script -* Version: 1.0.0 -* -* -* Author: Prabhjit Singh -* Purpose: UE script for testing to set custom field on record -* this will notify on the PDF if the PDF was printed or reprinted -* and is a helpful tool to track if users are repriting the PDF/record -* -************updates from test ******************* -* testing in other context => beforeload//beforesubmit//aftersubmit -* so far only beforeload does anything on the refresh -* -* ******************************************************************* */ -/** -*@NApiVersion 2.x -*@NScriptType UserEventScript -*/ -define(['N/record', 'N/render', 'N/runtime', 'N/search'], (record, render, runtime, search) => { - const NS_CONSTANT = { - CLASS: { - DIRECT: 4, - DROPSHIP: 6 - }, - ROLES: { - DEV: 1446, - MANAGER: 1590, - SALES_REP: 2810 - } - } - const beforeLoad = (context) => { - try { - //do print work needed for printing - doPrintWork(context); - /* thinking about adding a button and then firing a script to print. Using render>> - doens't work// keeps looking the pdf and re-running script - */ - const acceptedContext = ["create", "copy"]; - - if (acceptedContext.includes(context.type)) { - //other processing work - initialBuilder(context); - } - } catch (error2) { - log.debug({ title: 'ERROR BeforeLoad', details: `error2: ${error2}` }); - } - } - const initialBuilder = (context) => { - try { - const newRec = context.newRecord; - if (!newRec) { return; } - const usrObj = runtime.getCurrentUser(); - const cust = newRec.getValue({ fieldId: 'entity'}); - //if sales rep - if (usrObj.id == NS_CONSTANT.ROLES.SALES_REP) { - newRec.setValue({ fieldId: 'custbody_created_by_mg', value: 'sales rep' }); - newRec.setValue({ fieldId: 'custbody_checkbox_salesapp', value: true }); - newRec.setValue({ fieldId: 'class', value: NS_CONSTANT.CLASS.DIRECT }); - } - if(cust){ - const busType = search.lookupFields({ - type: search.Type.CUSTOMER, - id: cust, - columns: ['custent_cust_type'] - }).custent_cust_type; - !!busType ? newRec.setValue({ fieldId: 'custbody_bs_type', value: busType }) : newRec.setValue({ fieldId: 'custobody_cus_multi', value: [2,4,8] }); - } - } catch (error) { - log.error({ title: 'ERRORf initialBuilder', details: error }); - } - } - const doPrintWork = (context) => { - if (context.type == context.UserEventType.PRINT) { - try { - var recID = record.id; - var recType = record.type; - } catch (error1) { - log.error({ title: 'doPrint Error', details: 'error1: ' + error1 + 'JSON error: ' + JSON.stringify(error1) }); - } - try { - var rec = record.load({ - type: record.Type.SALES_ORDER, - id: 4606 - }); - var reprinted = rec.setValue({ - fieldId: 'custbody100', - value: 'Reprinted' - }); - log.debug({ title: 'Catch', details: 'reprinted: ' + reprinted }); - var getreprinted = rec.getValue({ fieldId: 'custbody100' }); - log.debug({ title: 'DEBUG', details: 'getprinted: ' + getreprinted }); - rec.save({}); - - return; - - } catch (error) { - log.debug({ title: 'ERROR doPrintWork', details: `error: ${error}` }); - } - - } else if (context.type != context.UserEventType.PRINT) { - log.debug({ title: 'DEBUG', details: `NOT PRINT context THEREFORE DO NOTHING!!` }); - } - } - - return { - beforeLoad - } -}); diff --git a/SuiteScripts/UE_SS2_invoke_Mapreduce.js b/SuiteScripts/UE_SS2_invoke_Mapreduce.js deleted file mode 100644 index 6980c7e..0000000 --- a/SuiteScripts/UE_SS2_invoke_Mapreduce.js +++ /dev/null @@ -1,38 +0,0 @@ -/******************************************************************* -* -* -* Name: UE_SS2_invoke_Mapreduce.js -* Script Type: UserEvent Script -* Version: 1.0.0 -* -* -* Author: Prabhjit Singh -* Purpose: invoke Map_Reduce script using the task module -* -* -* ******************************************************************* */ -/** - * @NApiVersion 2.x - * @NScriptType UserEventScript - * @NModuleScope SameAccount - */ -define(['N/task'], - -function(task) { - - function afterSubmit(scriptContext) { - var mrTask = task.create({ - taskType: task.TaskType.MAP_REDUCE, - scriptId: "customscript460", - deploymentId: "customdeploy1" - }); - log.debug(mrTask); - - var mrTaskId = mrTask.submit(); - log.debug(mrTaskId); - } - return { - afterSubmit: afterSubmit - }; - -}); \ No newline at end of file diff --git a/SuiteScripts/UE_ss1_lockrecord.js b/SuiteScripts/UE_ss1_lockrecord.js deleted file mode 100644 index d820d15..0000000 --- a/SuiteScripts/UE_ss1_lockrecord.js +++ /dev/null @@ -1,42 +0,0 @@ -/******************************************************************* -* -* -* Name: UserEvent Lock Record -* Script Type: UserEvent Script -* Version: 1.0.0 -* -* -* Author: prabhjitsinghdev -Prabhjit Singh - -* Purpose: this script removes the edit button -* & is a work around for those who want to lock the record -* If the user role is not the Administrator then they cannot edit the record -* -* -* ******************************************************************* */ -/** -*@copyright 2024 -*@author prabhjitsinghdev -*/ - -function beforeload(context) { - if (type == 'view') { - if (nlapiGetRole() !== 3) { - form.removeButton('edit'); - nlapiLogExecution('DEBUG', 'removebutton', 'done'); - } - } - else if (type == 'edit') { - //if the user clicks EDIT in the list view - //we check this here and then proceed or not allow them - if (nlapiGetRole() == 3) { - nlapiLogExecution('DEBUG', 'equals 3', 'continue'); - - } else { - form.removeButton('save'); - alert('You are not Administrator; closing window'); - setTimeout(function () { window.close(); }, 5000); - } - } -} diff --git a/SuiteScripts/UserEvent/UE_SS2_invoke_Mapreduce.js b/SuiteScripts/UserEvent/UE_SS2_invoke_Mapreduce.js index 6980c7e..8c27aa4 100644 --- a/SuiteScripts/UserEvent/UE_SS2_invoke_Mapreduce.js +++ b/SuiteScripts/UserEvent/UE_SS2_invoke_Mapreduce.js @@ -16,23 +16,29 @@ * @NScriptType UserEventScript * @NModuleScope SameAccount */ -define(['N/task'], +define(['N/task', 'N/runtime'], (task, runtime) => { + const RESOURCES = { + SCRIPTS: { + MR_CHECKLIST: { + SCRIPTID: "customscript460", + DEPLOYID: "customdeploy1" -function(task) { + } + } + } + const afterSubmit = (scriptContext) => { + if (runtime.executionContext != runtime.ContextType.USER_INTERFACE) { + let mrTask = task.create({ + taskType: task.TaskType.MAP_REDUCE, + scriptId: RESOURCES.SCRIPTS.MR_CHECKLIST.SCRIPTID, + deploymentId: RESOURCES.SCRIPTS.MR_CHECKLIST.DEPLOYID + }); + let mrTaskId = mrTask.submit(); + log.debug({ title: "DEBUG", details: mrTaskId }); + } + } + return { + afterSubmit + }; - function afterSubmit(scriptContext) { - var mrTask = task.create({ - taskType: task.TaskType.MAP_REDUCE, - scriptId: "customscript460", - deploymentId: "customdeploy1" - }); - log.debug(mrTask); - - var mrTaskId = mrTask.submit(); - log.debug(mrTaskId); - } - return { - afterSubmit: afterSubmit - }; - }); \ No newline at end of file diff --git a/SuiteScripts/restlet_SS1_postRecord.js b/SuiteScripts/restlet_SS1_postRecord.js deleted file mode 100644 index bb6f9be..0000000 --- a/SuiteScripts/restlet_SS1_postRecord.js +++ /dev/null @@ -1,62 +0,0 @@ -/******************************************************************* -* -* -* Name: Restlet POST record -* Script Type: Restlet Script -* Version: 1.0.0 -* -* -* Author: pj92singh -Prabhjit Singh - -* Purpose: RESTlet ss1.0 takes in the JSON data paramters -And using the post function it will -create a record and checks if sales order then adds line item -* -* -* ******************************************************************* */ - -function postRESTlet(datain) { - // body... - nlapiLogExecution('DEBUG', 'post function', 'POST'); - - try{ - var record = nlapiCreateRecord(datain.recordtype); - - record.setFieldValue('entityid', datain.entityid); - record.setFieldValue('companyname', datain.companyname); - record.setFieldValue('email', datain.email); - //record.setFieldValue('subsidiary', datain.subsidiary); - record.setFieldValue('memo', datain.memo); - - //checking JSON data-in for SalesOrder recrody type - if (datain.recordtype == 'salesorder') - { - record.setFieldValue('customer', datain.entityid); - record.setFieldValue('subsidiary', datain.subs); - nlapiLogExecution('DEBUG', 'rec = salesorder', 'addingline item'); - var item1 = datain.item.id; - nlapiLogExecution('DEBUG', 'item1', 'item1:: '+item1); - var item1_qty = datain.item.quantity; - nlapiLogExecution('DEBUG', 'item1_qty', 'item1_qty:: '+item1_qty); - - var line1 = nlapiSelectLineItem('item', 1); - record.setCurrentLineItemValue('item', 'item', item1); - record.setCurrentLineItemValue('item', 'quantity', item1_qty); - record.commitLineItem('item'); - - } - - - var recordId = nlapiSubmitRecord(record); - nlapiLogExecution('DEBUG', 'id='+recordId); - - var nlobj = nlapiLoadRecord(datain.recordtype, recordId); - - }catch(error){ - nlapiLogExecution('DEBUG', 'catch error', 'error: ' +error); - } - - return nlobj; - -}