I am getting the error “You must use getValue to r...
# suitescript
c
I am getting the error “You must use getValue to return the value set with setValue.” when trying to access the text value of a field in “before submit”. On save of the opportunity, I want to get the name of the salesperson and save it into the title of the record. is it possible to use getText to get the name selected in the salesrep field?
Copy code
scriptContext.newRecord.getText("salesrep"),
e
Is the script your working on (or another beforeSubmit script) set the Sales Rep? That's what the error is saying. If you set the sales rep using .setValue, you can only retrieve the value, not the text. This drove me crazy for a while until I realized that I was indeed setting a sublist value (in a different script) and so I was unable to use .getText in the script I was working on.
A workaround would be to use search.lookupfields and search employees for their name based on their ID - though you will likely run into the issue that users who are saving an opportunity may not have permissions to view employee records
c
It’s actually being set on the form (entered into the native List/Record field) — then I am trying to get the text value - either before submit or after, it doesn’t really matter to me
What is odd, is this same code was working last week, the error just started happening today
e
this code doesn't work on an after submit call either?
Copy code
scriptContext.newRecord.getText("salesrep"),