I have created a custom field on a custom record t...
# suitescript
r
I have created a custom field on a custom record trough serverWidget Module in beforeLoad Uservent
Copy code
projectPromotionField = form.addField({
	id: 'custpage_project_promotion',
	type: serverWidget.FieldType.SELECT,
	label: 'Promotion'
})
Also setting the default Value of this field in the same beforeLoad
Copy code
projectPromotionField.defaultValue = 'xyz'
Now if I am changing this field value. In afterSubmit I am able to fetch from the newRecord but not the oldRecord
Copy code
promotion = context.newRecord.getValue('custpage_project_promotion')
But this is always coming empty
Copy code
oldPromotion = context.oldRecord.getValue('custpage_project_promotion')
Any specific reason why field is not available in context,oldRecord?
c
I assume it’s not in old record because that’s a copy of what’s in the database. The field you’re using is not permanent & doesn’t exist on the persisted record
b
I am currently using the same approach, What I'm doing is on beforeSubmit, I would save the values on a custom field and will pull it again
z
@raghav Do you know difference between FORM and DATABASE TABLE? Who told you that. addField ADD CUSTOM FIELD TO. THE CUSTOM RECORD???
r
I ended up fetching the value from api call again. Another option was using the session module.
@Zoran R-DATAGRAM we had a requirement where the drop-down needed to be populated dynamically based on data in another db. That data is not available in Netsuite. Creating a field and storing data was not agreed upon. It was just for a user's view on a record which doesn't get much interaction.
z
Ok, now we are aligned. record.getValue retrieves data from "database table"... if you don't store how do you expect value in command oldRecord.getvalue? @bt provided where clean explanation
r
newRecord.geValue works though. It was a unique interaction where the field doesn't come in the context of the old record but comes in a new record which I was unaware about previously. Anyway I have already got the answer I needed. Thanks for your input.