N/search search.run is not triggering on afterSubm...
# ask-stanley-ai
s
N/search search.run is not triggering on afterSubmit in Deposit Application record
c
AI generated answer (using internal Slack threads):
Based on the conversations, it seems that the issue is related to the use of
N/search
in the
afterSubmit
event of a Deposit Application record. In the first thread, the user is trying to run a search on the
depositapplication
record type, but is encountering an error. The community suggests that
depositapplication
is not a valid type for searches, and recommends creating the search in the UI first, then loading the created search in the script and inspecting its filters. In the second thread, the user is encountering an error when trying to access the
id
of
oldRecord
in the
afterSubmit
event. The community suggests that this error might occur because
oldRecord
does not exist when the record is being created. They recommend adding a condition to check if
oldRecord
exists before trying to access its
id
. Here is the suggested code:
Copy code
javascript
const afterSubmit = (context) => {
    const contextDepApp = context.oldRecord;
    if (!contextDepApp) return;
    const depAppId = contextDepApp.id;
    const soEntity = contextDepApp.getValue({
        fieldId: 'customer'
    });
}
In the third thread, the user is trying to join Deposit Application with an Invoice saved search but is unable to find a way to do so. The community suggests trying to use paying transaction join fields at the saved search. ****** 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.819228172
Slack thread 2: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.807059288
Slack thread 3: here (available only if the original thread was posted in the last 90 days)
Similarity score: 0.805072308
Please provide your feedback on this answer.