Hello, is it possible to disable or make inline “O...
# suitescript
s
Hello, is it possible to disable or make inline “Override” checkbox on address form?
a
I want to say I did this a while back with a script...
s
@al3xicon Can you please share the code snippet, it you have it?
a
I'll see if I can dig it up, it was at a prior company when I wrote it...
Copy code
/**
 * @NApiVersion 2.x
 * @NScriptType ClientScript
 * @NModuleScope SameAccount
 */
define(['N/ui/message'],
/**
 * @param {message} message
 */
function(message) {
  
  /**
   * Validation function to be executed when record is saved.
   *
   * @param {Object} scriptContext
   * @param {Record} scriptContext.currentRecord - Current form record
   * @returns {boolean} Return true if record is valid
   *
   * @since 2015.2
   */
  function saveRecord(scriptContext) {
  	var _rec = scriptContext.currentRecord;
  	var ship_addr_override = _rec.getValue({fieldId:'shipoverride'});
  	if (ship_addr_override == 'T') {
  		// show message
  		var msg = message.create({
  			title: 'Shipping Address Override',
  			message: 'You cannot save this transaction, because the shipping address has the "Override" box checked. Please fix this before saving.',
  			type: message.Type.ERROR
  		});
  		msg.show({duration: 5000});
  		return false;
  	} else {
  		return true;
  	}
  }

  return {
    saveRecord: saveRecord
  };
    
});
so this doesn't do what you were looking for exactly - but it does prevent a user from saving a transaction record if there is an address with the override box checked
s
thanks @al3xicon , much appreciated
m
You can add a client script to the Address form that disables the field
a
That's what I assumed I had done, but was surprised that I hadn't. That's definitely the way to go.