RE: How to dynamically add a record type?

When dynamically adding record type I get the following error:

The record type [RECORD.TYPE.WORK_ORDER_ISSUE] is invalid.

Here is the function:

async function transform(recObj){
            try{
            let curRecord = await record.transform.promise({
                fromType: recObj.fromType,
                fromId: recObj.fromId,
                toType: recObj.toType,
                //toType: record.Type.WORK_ORDER_ISSUE,
                isDynamic: false
            })
            log.debug(‘157’, curRecord);
            await curRecord.save.promise();
            return curRecord;
}
if I replace

                fromType: recObj.fromType,
                toType: recObj.toType,
with      fromType: record.Type.WORK_ORDER,
                toType: record.Type.WORK_ORDER_ISSUE,
if works fine without errors.
values for :
fromType is record.Type.WORK_ORDER  a string
toType is record.Type.WORK_ORDER_ISSUE a string
rem2070 Rookie Asked on March 21, 2024 in SuiteScript.
Add Comment
2 Answers
Best answer

Hi,

So is the string ‘record.Type.WORK_ORDER’?

If so, that will not work. Are you not able to pass record.Type.WORK_ORDER directly to the function?

Failing this, since these are enumerations, you can just use the string they represent, i.e. ‘workorder’.

Thanks,

Chris

Advanced Answered on March 22, 2024.
Add Comment

Your Answer

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