I have a 2.0 script that hides fields based on a f...
# suitescript
p
I have a 2.0 script that hides fields based on a field value and that works fine in edit mode. (The value that determines if the other field is hidden is populated via a workflow). But in view mode the fields still appear. How can I have the fields not appear in view?
Copy code
define([], function () {

    function hideFields(context) {
    
    if(context.fieldId = "custbody_myfield") {
    var jobElementValue = context.currentRecord.getValue({ fieldId: "custbody_myfield" });
    var hidethisfield = context.currentRecord.getField({ fieldId: "custbody_fieldx" });
    
    if (jobElementValue == "hideme") {
    hidethisfield.isDisplay = false;
    
    } else 
    if (jobElementValue == "showme")
    {
    hidethisfield.isDisplay = true;
    }
    }
    }
    
    return {
    pageInit: hideFields
    }});
    /* End Hide Fields */
s
You need to change the architecture if you want to hide fields in view mode. Client scripts do not run in view mode, so the fields would need to be hidden in a beforeLoad UserEvent.