Hi Guys, How I can update the lebel of a field usi...
# suitescript
n
Hi Guys, How I can update the lebel of a field using script?
k
Would use workflow, its lighter
c
I dispute that workflows are lighter. They're also a pain to maintain
💯 2
k
Biggest advantage of workflows, at least according to Netsuite is that they run in parallel
n
can I use a UE and in beforeLoad I can change the lebel, it is based on some conditions
do we have any api like field.lebel or somethiing?
var field = form.getField({id:'yourfieldid'}); field.label = 'New _LAbel_';
n
yeah thanks @tuli I’m using same var field = form.getField({id:‘vatregnumber’}); field.label = ‘VAT ID Number’;
but the issue is in view mode it is not working
I’m using BeforeLoad it is working in edit mode only not in VIEW mode! can you please let me know here what I can do to see the updated lable in View mode too??
k
bit of a hack but you could add inline html field and run js there
n
thanks @Kyriakos Zisopoulos I’ll definitly use it if I don’t get an simple thing which I can do just using the same user event!
t
Its working in view mode as well
Its UE not CS
message has been deleted
n
Is that a standard field or custom field?
Mine is not showing in view!!?
t
I tried on custom
n
mine is standard, I don’t know if that matters but its not working in VIEW for me!!
Copy code
/**
 *@NApiVersion 2.x
 *@NScriptType UserEventScript
 */
define(['N/record'],
    function(record) {
        function beforeLoad(context) {
            if (context.type == context.UserEventType.EDIT || context.type == context.UserEventType.VIEW){

                var cust = context.newRecord;
                var form = context.form;
                var formId = cust.getValue({fieldId:'customform'});
                log.debug('form id',formId);
              
                var subsi = cust.getValue({fieldId:'subsidiary'});
            
                if(formId == '162'){
                if(subsi == '6' || subsi == '10' || subsi == '12' || subsi == '7' || subsi == '8'){
                    var field = cust.getField({id:'vatregnumber'});
                    field.label = 'VAT ID Number';
                    
                 
                  log.debug('field label',field.label);
                }
                }

            }
                
                
        }

        
        
        return {
            beforeLoad: beforeLoad
            
        };
    });
code is like this
t
Here I changed the field id to createdfrom
on item receipt and result is same
message has been deleted
function beforeLoad(context) {
var form = context.form;
var field = form.getField({id:'createdfrom'});
field.label = 'New LAbel';
}
Here is my before load function
n
can you check this for Tax Reg. Number on Customer form? this is a std field and I’m checking for this but in VIEW mode its not working! please let me know if it works for you!
c
Pretty sure
var cust = context.newRecord;
will be wrong for
VIEW
Did you sort this?
n
yeah I sorted it using workflow and Client script