single contact that was linked to multiple compani...
# ask-stanley-ai
t
single contact that was linked to multiple companies how to get those company by script
c
AI generated answer (using internal Slack threads):
****** Disclaimer: This response was generated by an artificial intelligence assistant based on previous conversations from multiple Slack channels, and may contain inaccuracies or mistakes. ****** To get the companies linked to a single contact by script, you can use the
record.detach
method in SuiteScript. This method is used to remove a link between two records. Here is a sample code snippet:
Copy code
javascript
var contactRecord = record.load({
    type: record.Type.CONTACT, 
    id: contactId
});

var companySublistCount = contactRecord.getLineCount({
    sublistId: 'sublistId' // replace 'sublistId' with the actual sublist id
});

for (var i = 0; i < companySublistCount; i++) {
    var companyId = contactRecord.getSublistValue({
        sublistId: 'sublistId', // replace 'sublistId' with the actual sublist id
        fieldId: 'company', // replace 'company' with the actual field id
        line: i
    });

    record.detach({
        record: {
            type: record.Type.COMPANY,
            id: companyId
        },
        from: {
            type: record.Type.CONTACT,
            id: contactId
        }
    });
}
Please replace 'sublistId' and 'company' with the actual sublist id and field id respectively. This script will detach the contact from all the companies it is linked to. If you want to fix this issue from a CSV, you might need to re-import the CSV with the correct data. Make sure to check the "OVERWRITE SUBLISTS" option under the Advanced options section while importing. This should remove the extras and keep only what you have in your CSV file. If the CSV import doesn't work, you might need to write a script to fix the issue.
Slack thread 1: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.821861863
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.816372633
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.801981211
Please provide your feedback on this answer.