Is this allowed? ```record.transform({ fromTy...
# suitescript
c
Is this allowed?
Copy code
record.transform({
    fromType: record.Type.CUSTOM_SALE,
    fromId: customSaleRecordId,
    toType: record.Type.INVOICE,
    isDynamic: false
})
Testing suggests you cannot transform a customsale record (custom transaction with style set to sale) into an invoice.
n
Instead of this record.Type.CUSTOM_SALE can you use the custom transaction type?
c
Copy code
Error: Transaction type specified is incorrect.
Looks like I cannot
n
Seems that way. But what did you use?
c
I used the scriptid of the custom transcation
👍 1
I read somewhere that this transform would work but I wasn't holding my breath.
n
Do you have the "invoice" button on your custom transaction?
c
Yes
UE script to add an invoice button CS to redirect to a Suitelet Suitelet to create the invoice
n
Oh. I was referring to the native one.
c
No, I'm not aware that it's possible to add the native invoice button here.
n
Perhaps that's why transform is also not supported.
c
Yeah, I'm not too surprised - I was just living in hope.
👍 1
m
yes this is definitely supported. i do it all the time in workflow using Transform Record action https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_4267258715.html#bridgehead_4327469981
Setup a workflow and add a custom button called "Invoice" or next bill Then use transform record action to make the invoice
c
@MGBC Not from my testing.
Not sure what I'm missing with that transform code.
m
Are you trying to do this with a User Event or scheduled script?
c
Suitelet
n
It does support it, it seems based on the docs shared by @MGBC
m
try setting from type to 'customsaletransaction'
☝️ 1
n
Use "customsalestransaction" as type
c
Maybe I was passing in the wrong internal ID; that's the only thing I can think of - I'll test this again.
m
and use 'invoice' for toType
c
Copy code
record.Type.INVOICE
n
Use "customsalestransaction" as type
c
image.png
it should really accept what's in the ENUM
as they just map to the same string
m
var objRecord = record.transform({ fromType: 'customsalestransaction', fromId: 107, toType: 'invoice', isDynamic: false, });
c
I will test that but that's breaking the standard pattern of using the enum
but I see the enum might be wrong for this?
Copy code
this.CUSTOM_SALE = 'customsale';
and that's in record.js (the suitescript library)
@MGBC
Copy code
"type": "error.SuiteScriptError",
  "name": "INVALID_RCRD_TYPE",
  "message": "The record type [CUSTOMSALETRANSACTION] is invalid.",
Copy code
function createInvoiceFromCustomSalesTransaction() {
    return record.transform({
        fromType: 'customsaletransaction',
        fromId: 260648,
        toType: 'invoice',
        isDynamic: false
    })
}
I agree that the docs say it should work - I am not able to reproduce what the docs are saying though
n
And what happens when you use your transaction type script id?
c
@NickSuite different error actually
Copy code
"type": "error.SuiteScriptError",
  "name": "INVALID_TRANS_TYP",
  "message": "Transaction type specified is incorrect.",
crying sunglasses 1
It's interesting how that gives a different exception