is it possible to have a fieldchanged script fire ...
# suitescript
p
is it possible to have a fieldchanged script fire only if a field has a certain value? Im using ss 1.0.
b
usually done within the fieldChanged function itself
its essentially mandatory to at least check the name parameter
p
what i am trying to do is set a line field value when the quantity of the line item is changed but only if the cost estimate type is preferred. I have the following but not sure how to make it only fire based on the cost esitmate type:
if ((type == 'item') && (name == 'quantity') && (name == 'costitemtype'))
b
that condition is equivalent to false
name cant be equal to both quantity and costitemtype
you should get the field value of the cost estimate type to check its value
j
you want something like this
Copy code
function FieldChanged(type, name) {

	// Check that we changed the quantity for anitem.
	if(type == 'item' && name == 'quantity') {

		// Check that the cost estimate type is whatever value we need it to be
		var cet = nlapiGetCurrentLineItemValue('item', 'custitemtype');

		if(cet == /* put your check value here */) {

			// execute the rest of your code here

		}

	}

}
p
Thanks Jen. I was able to get it to work earlier today - exactly how you did it.