How can I get the text of a field of my newRecord?...
# suitescript
c
How can I get the text of a field of my newRecord? When I use the getText function I get "Invalid API usage. You must use getValue to return the value set with setValue."
r
For some fields only you ca use getText('fieldId');
which type of field you are trying to gettext?
n
Show us some code! Also tell us which field type is it?
c
It's a list I'm trying to get the text value of instead of the ID.
// Let's get the current new record and the customer ID of it's parent
var currRecord = context.newRecord;
// Retrieve field values for type of treatment and date of today
var treatmentType = currRecord.getText({fieldId: 'custrecord_vq_minuten_behandeling'});
It's a list based on items and I'm trying to get the name of the item instead of the internal ID.
b
I've never seen that before, but it sounds like you are trying to get the text of a field in beforeSubmit. The text might not be loaded yet, which is why its telling you to use getValue.
c
VQ_Behandelcode.js
ah yes I'm trying to use it in the beforeSubmit
b
you can try making it afterSubmit
c
will do
b
the alternative is that you use the field options
c
afterSubmit gives the same error so I guess I will have to lookup field options as you say
b
if you are already in afterSubmit, you can use search.lookupFields to lookup the values
c
I see, will look that up. I'm setting my first steps with suitescript šŸ™‚
n
Well, Good luck, you'll need that. But jokes aside, you will get a lot of help and your vast knowledge will increase for sure here.
c
Cheers, will get there step by step
šŸ‘šŸ» 1
e
@Christiaan Welcome to the SuiteScript world! Here are a few great resources for learning: * https://leanpub.com/netsuitedevelopment by @mattdahse • https://www.youtube.com/c/StoicSoftware • https://stoic.software/learn/