Hi guys, Is there a way to hide the amount rate t...
# suitescript
a
Hi guys, Is there a way to hide the amount rate tax gross amount fields via script in a transaction record? I tried using the script, but it only hides them in edit mode when the view isn't triggered. Can I use DOM manipulation to hide fields in a transaction record? For example, using a Purchase Order transaction, etc. Thanks.
c
Don't manipulate the DOM, that's a terrible idea. Doesn't this work in a UE beforeLoad? field.updateDisplayType({ displayType: serverWidget.FieldDisplayType.HIDDEN });
What have you actually tried?
a
Hi , Sorry for late Response, I direct user Form.field.UpdateDisplayType, /** * @NApiVersion 2.1 * @NScriptType UserEventScript */ define(['N/log'], (log) => { const beforeLoad = (context) => { if ( context.type !== context.UserEventType.VIEW && context.type !== context.UserEventType.EDIT && context.type !== context.UserEventType.CREATE ) { return; } try { let newRecord = context.newRecord; let form = context.form; // 1. Ambil nilai custom field Checkbox let staffForm = newRecord.getValue({ fieldId: 'custbody_lf_is_staff_form', }); // Cek di Execution Log untuk memastikan tipe datanya log.debug( 'Cek Flag Staff Form', 'Nilai custbody_lf_is_staff_form: ' + staffForm + ' | Tipe: ' + typeof staffForm, ); // 2. PERBAIKAN: Gunakan boolean true, bukan string 'T' if (staffForm === true) { let itemSublist = form.getSublist({ id: 'item' }); if (itemSublist) { const sublistFieldsToHide = [ 'amount', 'rate', 'taxcode', 'taxrate1', 'tax1amt', 'grossamt', 'custcol_4601_witaxapplies', 'custcol_4601_witaxbaseamount', 'custcol_4601_witaxcode', 'custcol_4601_witaxrate', 'custcol_4601_witaxamount', 'custpage_4601_witaxbaseamount', 'custpage_4601_witaxamount', ]; sublistFieldsToHide.forEach((fieldId) => { let field = itemSublist.getField({ id: fieldId }); if (field) { field.updateDisplayType({ displayType: 'HIDDEN' }); } }); } const headerFieldsToHide = ['total', 'subtotal', 'taxtotal']; headerFieldsToHide.forEach((fieldId) => { let headerField = form.getField({ id: fieldId }); if (headerField) { headerField.updateDisplayType({ displayType: 'HIDDEN' }); } }); } } catch (error) { log.error({ title: 'Error Hiding Amount Fields on PO', details: error.message || error, }); } }; return { beforeLoad: beforeLoad, }; });
c
Try to wire a very minimal script just to hide the field in question, then you know if it's impossible to hide or a logic error in your larger script.
a
thank you , i used Enum serverWidget.FieldDisplayType.HIDDEN instead string 'HIDDEN' and Success to hide field.
c
Perfect, that means it is a logic error in your larger script.
a
Hi Craig @Craig is possible to hide amount in this section too ? Thanks