Filter out transactions in a search which have a c...
# ask-stanley-ai
s
Filter out transactions in a search which have a custom record that is referencing them via a List/Record field.
c
AI generated answer (using internal Slack threads):
To filter out transactions in a search which have a custom record that is referencing them via a List/Record field, you can use the following steps: 1. Create a custom field on the transaction record that references the custom record. This field should be of type List/Record and should be linked to the custom record. 2. In the custom field setup, under the 'Sourcing and Filtering' tab, set up the necessary filters to only include the custom records that you want to reference. 3. Create a saved search on the transaction record. In the criteria of the saved search, include a filter for the custom field you created. Set the filter to 'none of' and select the custom records that you want to exclude. 4. In the results of the saved search, you can include any fields from the transaction record that you want to display. Here is a sample code snippet for creating the custom field:
Copy code
javascript
var customField = record.createField({
    id: 'custfield_my_custom_field',
    type: record.Type.LIST,
    label: 'My Custom Field'
});
customField.update({
    filter: {
        type: record.Type.CUSTOM_RECORD,
        filters: [
            {
                name: 'custrecord_my_custom_record_field',
                operator: search.Operator.NONEOF,
                values: ['@NONE@']
            }
        ]
    }
});
And here is a sample code snippet for creating the saved search:
Copy code
javascript
var mySearch = search.create({
    type: "transaction",
    filters:
    [
        ["custfield_my_custom_field","noneof","@NONE@"]
    ],
    columns:
    [
        search.createColumn({name: "tranid", label: "Document Number"}),
        search.createColumn({name: "status", label: "Status"})
    ]
});
Please replace 'custfield_my_custom_field', 'custrecord_my_custom_record_field', and other placeholders with your actual field and record IDs. ****** 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.82230252
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.820921779
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.818222523
Please provide your feedback on this answer.