Is there any easier way to check/assign a variable...
# suitescript
d
Is there any easier way to check/assign a variable from an array that is returned by search.lookupfields?
Copy code
var tranData = search.lookupFields({
	type: 'transaction', 
	id: tranID, 
	columns: ['type', 'createdfrom', 'tranid'] 	
});

var tranType = tranData.type[0].value;	//	ALWAYS RETURNS VALUE
var createdFrom = tranData.createdfrom[0].value	//	MAY NOT ALWAYS RETURN A VALUE & WILL ERROR WHEN UNDEFINED

// MY FIX, BUT IT FEELS DIRTY
if (tranData.createdfrom.length > 0) createdFrom = tranData.createdfrom[0].value;
e
Create a function like NVL and evaluate each returned value from the lookupFields
d
Excellent! Thanks for the tip!