This message was deleted.
# suitescript
s
This message was deleted.
a
can you provide the full error msg as well?
c
Transaction type specified is incorrect.
a
sorry... full error OBJECT 🙂
c
and nothing in the system notes other than the log.debug strings (No system error)
a
... err what?
c
indeed
a
so the "error" you're getting is... in the UI on submit?
c
yes
} catch (error) { log.debug('Could not find record', recordType); return false; } I think this might be swallowing the system error
a
why do you think its this script that is erroring?
c
Because it's the only script on the custom record which generates the user event
and nothing deployed on VB
a
ugh... ok can you add log.error({ title: 'error caught', details: JSON.stringify(e)});
c
{"type":"error.SuiteScriptError","name":"INVALID_TRANS_TYP","message":"Transaction type specified is incorrect.","id":"","stack":["createError(N/error)","afterSubmit(/SuiteScripts/RejectReason.js:20)"],"cause":{"type":"internal error","code":"INVALID_TRANS_TYP","details":"Transaction type specified is incorrect.","userEvent":"aftersubmit","stackTrace":["createError(N/error)","afterSubmit(/SuiteScripts/RejectReason.js:20)"],"notifyOff":false},"notifyOff":false,"userFacing":false}; ID:
a
line 20? is that the VB erroring out then? or the PO attempt?
c
That's the PO, which should be captured in the catch allowing the user to progress.
maybe it's not caught because of the return statement?
a
right... which it is doing... and then updating the VB without issue
c
the user is getting stopped in the UI though
The user can't proceed in the UI. Notice: Transaction type specified is incorrect.
a
Untitled.js
yeah ok this is just annoying... rewrite it the design is awful anyway
c
Yeah, I've spent more time on this than what I would have spent writing it properly.
a
LOL same 🙂
which is why i just rewrote it cos it was quicker
😂 1
I mean it literally took 10minutes
c
Copy code
function getTransactionType(internalId) {
    const filters = [['internalid', 'is', internalId]]; // Define search filter
    
    const transactionSearch = search.create({
        type: search.Type.TRANSACTION,
        filters: filters
    });

    const searchResult = transactionSearch.run().getRange({start: 0, end: 1});

    if (searchResult.length > 0) {
        return searchResult[0].recordType;
    }

    return null;
}
👍 1
No more guessing the trantype 🙂
a
... you saw that I did this in the snippet I pasted above already using a lookupfields?
you just dont like lookupfields?
c
Fair point, far more concise that way
a
i mean its your code man, what ever you like is good
c
Concise is often better
Thanks for the rubber ducking/debugging help.
👍 1