vennila ramasamy
10/18/2022, 9:40 AMKyriakos Zisopoulos
10/18/2022, 12:12 PMvennila ramasamy
10/18/2022, 12:37 PMJessicaL
10/18/2022, 1:13 PMvennila ramasamy
10/18/2022, 1:53 PMvennila ramasamy
10/18/2022, 1:54 PM/**
* @NApiVersion 2.x
* @NScriptType UserEventScript
* @NModuleScope SameAccount
*/
//------------------------------------------------------------------
//Script Name: UE_Add_Button_Isabel_Status
//Customer: CMB
//Deployed on Record: Payment File Administration
//Script Type: UserEvent (beforeLoad)
//Description: Added three buttons on PFA and the functionality to those buttons is linked
// via the client sctipt 'CMB_cs_pfa_functions.js'
//Date: 05/10/2022
//Owner: Vennila Ramasamy
//Last Modified Date: 17/10/2022
//Last Modified By: Vennila Ramasamy
//Tags:
//------------------------------------------------------------------
define([
'N/ui/serverWidget',
'N/record',
'N/url',
'N/runtime',
'N/email'
],
function(serverWidget,record,url,runtime,email){
function beforeLoad(context){
var newRecord = context.newRecord;
var recordId = newRecord.id;
var isabelStatus = newRecord.getValue({fieldId : 'custrecord_cmb_isabel_status'});
var remindTreasury = newRecord.getValue({fieldId : 'custrecord_cmb_notice_treasury'});
var isibfvpp = newRecord.getValue({fieldId : 'custrecord_12793_is_ibf_vpp'});
log.debug('isibfvpp',isibfvpp);
var form = context.form;
form.clientScriptModulePath = './CMB_cs_pfa_functions.js';
/*In the If condition, the field "Isabel status" is checked and the relevant button either "Sent to Isabel" or
"Reset Isabel Status" is added via ClientScript CMB_cs_pfa_functions.js*/
if(!isabelStatus){
form.addButton({
id: 'custpage_senttoisabel',
label: 'Sent to Isabel',
functionName : 'checkIsabelStatus(' +recordId+ ')'
});
}else{
form.addButton({
id : 'custpage_resetisabelstatus',
label : 'Reset Isabel Status',
functionName : 'uncheckIsabelStatus(' +recordId+ ')'
});
}
/*Obtaining the current user ID and an object that represents the current script to fetch the value of the script parameter*/
var senderId = runtime.getCurrentUser().id;
var remindTreasuryRecipients = runtime.getCurrentScript().getParameter({
name: 'custscript_remind_treasury_recipients'
});
log.debug('remindTreasuryRecipients',remindTreasuryRecipients);
/*If the field "Treasury Reminded" is unchecked, the button "Remind Treasury" is added to send email notification to the employees(script parameters)
and the field "Treasury Reminded" is checked via ClientScript CMB_cs_pfa_functions.js*/
if (!remindTreasury && isibfvpp){
log.debug('if, show the button');
form.addButton({
id : 'custpage_remindtreasury',
label : 'Remind Treasury',
functionName : 'remindTreasury(' +recordId+ ',' +senderId+ ',' +remindTreasuryRecipients+ ')'
});
}
return true;
}
function aftersubmit(context){
log.debug('entering aftersubmit');
var newRecord = context.newRecord;
var contextType = context.type;
var isibfvpp = newRecord.getValue({fieldId : 'custrecord_12793_is_ibf_vpp'});
var senderId = runtime.getCurrentUser().id;
var remindTreasuryRecipients = runtime.getCurrentScript().getParameter({
name: 'custscript_remind_treasury_recipients'
});
log.debug('record id ',newRecord.id);
if(contextType === 'edit'){
log.debug('aftersubmit : if edit');
if(isibfvpp){
log.debug('aftersubmit : if isibfvpp');
email.send({
author : senderId,
recipients : remindTreasuryRecipients,
body : 'The notice is sent to Treasury',
subject : 'Notice sent to Treasury'
});
}
}
newRecord.save();
return true;
}
return{
beforeLoad : beforeLoad,
aftersubmit : aftersubmit
}
}
);vennila ramasamy
10/18/2022, 1:55 PMKyriakos Zisopoulos
10/18/2022, 1:56 PMvennila ramasamy
10/18/2022, 1:57 PMvennila ramasamy
10/18/2022, 1:58 PMJessicaL
10/18/2022, 2:00 PMvennila ramasamy
10/18/2022, 2:00 PMvennila ramasamy
10/18/2022, 2:03 PMJessicaL
10/18/2022, 2:03 PMvennila ramasamy
10/18/2022, 2:05 PMvennila ramasamy
10/18/2022, 2:05 PMvennila ramasamy
10/18/2022, 2:05 PMJessicaL
10/18/2022, 2:21 PMJessicaL
10/18/2022, 2:21 PMvennila ramasamy
10/18/2022, 2:30 PMvennila ramasamy
10/18/2022, 2:34 PMKyriakos Zisopoulos
10/18/2022, 2:34 PMJessicaL
10/18/2022, 2:35 PMJessicaL
10/18/2022, 2:35 PMvennila ramasamy
10/18/2022, 2:38 PMvennila ramasamy
10/18/2022, 2:39 PMJessicaL
10/18/2022, 2:41 PMJessicaL
10/18/2022, 2:41 PMbattk
10/18/2022, 2:46 PMbattk
10/18/2022, 2:46 PMvennila ramasamy
10/18/2022, 2:52 PMJessicaL
10/18/2022, 3:03 PMvennila ramasamy
10/18/2022, 3:06 PMJessicaL
10/18/2022, 3:07 PMvennila ramasamy
10/18/2022, 3:26 PM