Is it possible to attach a newly created record to...
# suitescript
t
Is it possible to attach a newly created record to a sublist on a custom record? The sublist in question is a list of these types of records, but I don’t know how I could just attach the new record to the sublist. I tried setting the line’s ID field to the new record’s ID, but that didn’t set the values for the other fields.
b
Is the sublist created by a parent/child relationship
t
Yes it is
b
Set the field used to create the relationship
alternatively use record.attach
t
would record.attach know that it belongs to the sublist?
b
You specify the field used for the parent/child relationship
t
would that be done in the attributes property?
b
yes
t
I’m getting this error: nlapiAttachRecord: Missing a required argument: attributes.field
Here is my attach method:
Copy code
record.attach({
    record: {
        type: 'customrecordcer_sor_billing_table',
        id: copiedSorTableId
    },
    to: {
        type: 'customrecordcer_sor',
        id: newSorRecordId
    },
    attributes: {
        custrecordcer_sorbt_sor: newSorRecordId
    }
})
I have verified that the copiedSorTableId and newSorRecordId have the appropriate values in them
b
Pay more attention to the error message
e
The error is telling you that you have no
field
property of
attributes
👍 1
t
hey guys, i’m dumb 🙂
e
well the docs/examples arent great
t
in my defense, i’m following the documentation which looks like this: attributes: { role: 3} });
right!
hey that worked! Thanks so much for your help @battk and thank you too @erictgrubaugh