Hello, anyone know how to display custom entity fi...
# suitescript
m
Hello, anyone know how to display custom entity field when vendor type is company in the vendor page? I try using this script but still didnt accomplished what I want.
Copy code
/**
 * @NApiVersion 2.0
 * @NScriptType UserEventScript
 * @NModuleScope SameAccount
 */
define(["N/record", "N/ui/serverWidget"], function (record, serverWidget) {
	function beforeLoad(context) {
		if (context.type === context.UserEventType.CREATE || context.type === context.UserEventType.EDIT) {
			var vendor = context.newRecord;
			var vendorType = vendor.getValue({ fieldId: "isperson" });
			var ownerFieldId = "custentity_owner_name"; 
			var positionFieldId = "custentity_positions"; 

			if (!vendorType) {
				context.form.getField({ id: ownerFieldId }).updateDisplayType({ displayType: serverWidget.FieldDisplayType.NORMAL });
				context.form.getField({ id: positionFieldId }).updateDisplayType({ displayType: serverWidget.FieldDisplayType.NORMAL });
			} else {
				context.form.getField({ id: ownerFieldId }).updateDisplayType({ displayType: serverWidget.FieldDisplayType.HIDDEN });
				context.form.getField({ id: positionFieldId }).updateDisplayType({ displayType: serverWidget.FieldDisplayType.HIDDEN });
			}
		}
	}

	return {
		beforeLoad: beforeLoad,
	};
});
c
To start with, you always need to return true from functions
👎 1
c
@Muhammad Hafiz Are you sure that
isperson
is returning a boolean and not a string? If it's returning the string
"F"
to indicate false, that lower block will never run.
m
I tried using vendorType = 'F' but still not working
v
try logging the isperson. sometimes, it has the 1 or 2 for True, false
b
first step is actually making sure you know how to make a field display normally, regardless of the isperson
then you figure out what value is in isperson so that you can write a condition for it