I'm trying to create a simple client script that w...
# suitescript
t
I'm trying to create a simple client script that will log a message when a button is pressed in the UI. However, I'm unsuccessful at getting the logged message to appear in the execution logs. Can functions called by a button on the screen not produce any logged messages? I'll put screenshots and code snippets in the threat -->
/** * @NApiVersion 2.x * @NScriptType ClientScript * @NModuleScope SameAccount * * 05/12/2022 Tim Pedersen - Adding functionality where the previous week's hours are collected and added to the current week's hours. * Unlike the other client script running on this recrd, this script is intended to also add the hours and memo from the previous week to the current week * This script will fire when a button is pressed, and only work in edit mode (not view mode). * */ define(['N/currentRecord', 'N/search', 'N/format'], function(currentRecord, search, format) { var isEdit = false; function pageInit(scriptContext) { if (scriptContext.mode == 'edit') isEdit = true; } function copyPreviousWeekAll() { var rec = currentRecord.get(); var employee = rec.getValue('employee'); var date = rec.getValue('trandate'); log.debug('employee', employee); log.debug('date', date); return true; }; return { pageInit: pageInit, copyPreviousWeekAll: copyPreviousWeekAll }; });
message has been deleted
a
For client scripts, you can do a console.log and see it in the browser console
šŸ‘ 2
If you want that
d
I think this is a limitation of client scripts that are added adhoc by UserEvent/Suitelet to Form and not truly deployed to a record type
t
I decided to just to a dialog alert instead. It appears that client script's don't log to the execution log.
z
you missed the answer... @Azi wrote the answer...if you want to learn something useful, read again and again @Azi answer
m
I have a client script that writes to the execution log of the suitelet script when clicked. I haven’t done anything other than add the log module to the client script and then use log.debug like usual
z
@Madelene Skƶld and how do you use client script with suitelet... share code please...
m
@Zoran R-DATAGRAM let form = serverWidget.createForm({ title: ā€˜Form Title’ }); form.clientScriptModulePath = ā€˜./client_script_file_name.js’; (if it’s not in the same folder as the suitelet script file you need to specify the full path rather than use the ā€œ./ā€ syntax)