I have a custom record and I want to attach my cus...
# ask-stanley-ai
m
I have a custom record and I want to attach my custom transaction to it. how can i do this ?
c
AI generated answer (using internal Slack threads):
To attach a custom transaction to a custom record, you can use the
record.attach
function in SuiteScript. Here is an example of how you can do this:
Copy code
javascript
record.attach({
    record: {
        type: 'customrecord_your_custom_record',
        id: 'your_custom_record_id'
    },
    to: {
        type: 'customtransaction_your_custom_transaction',
        id: 'your_custom_transaction_id'
    },
    attributes: {
        field: 'custbody_your_custom_field'
    }
});
In this example,
customrecord_your_custom_record
is the type of your custom record,
your_custom_record_id
is the ID of your custom record,
customtransaction_your_custom_transaction
is the type of your custom transaction,
your_custom_transaction_id
is the ID of your custom transaction, and
custbody_your_custom_field
is the custom field that holds the relationship between the two. Please note that the relationship should be set up correctly in the UI for this to work. The custom field should be of type list/record and the record should be your standalone custom record. Then, you can assign your custom record(s) to the transaction to create a join between the two. Also, please note that the
record.attach
function only supports attaching a child custom record to a parent transaction. If you need to attach a parent transaction to a child custom record, you might need to reverse the relationship. ****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ******
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.845825255
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.842102051
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.841247618
Please provide your feedback on this answer.