RE: Hi experts trying to create a phone call using suite scripts.

I tried crewating a phone call at the time of creating a new employee – an excercise .

* @NApiVersion 2.0
* @NScriptType UserEventScript


* @param {record} record
function(record) {

return {
afterSubmit: function(context){
//log.debug(‘Hello World’);
var employee = context.newRecord;

var empcode = employee.getValue(‘custentity_employee_code’);
var SuperVisorId = employee.getValue(‘supervisor’);
var SupervisorName = employee.getText(‘supervisor’);

if(context.type == context.UserEventType.CREATE){
var phoneCall = record.create({
type : record.type.PHONE_CALL,

phoneCall.setValue(‘title’, ‘Call HR for benifits’);



but Im getting this error.

{“type”:”error.SuiteScriptError”,”name”:”SSS_INVALID_API_USAGE”,”message”:”Invalid API usage. You must use getValue to return the value set with setValue. “,”stack”:[“anonymous(N/serverRecordService)”,”<anonymous>(/SuiteScripts/SuiteScript2/Sdr_ue_employee.js:21)”],”cause”:{“type”:”internal error”,”code”:”SSS_INVALID_API_USAGE”,”details”:”Invalid API usage. You must use getValue to return the value set with setValue. “,”userEvent”:”aftersubmit”,”stackTrace”:[“anonymous(N/serverRecordService)”,”<anonymous>(/SuiteScripts/SuiteScript2/Sdr_ue_employee.js:21)”],”notifyOff”:false},”id”:””,”notifyOff”:false,”userFacing”:false}

please provide a solution thanks

Pradeep Rookie Asked on September 9, 2020 in SuiteScript.
Add Comment
1 Answers

There are 2 ways of setting a field, using setValue and setText. if you set a field using setValue, you can only get its value using getValue. If you set a field using setText, then you can only get its text using setText. The supervisor field was set using setValue, so you can only get the internal id value of the supervisor using getValue.

Workaround is to use search.lookupFields (or use the slower record.load) to get your data instead

Intermediate Answered on September 9, 2020.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.