Custom Function Deluge Issue - Code Failing When In Approval Process

Custom Function Deluge Issue - Code Failing When In Approval Process

Hi,

I'm wondering if anyone can possibly help me with a problem we're having with Deluge.

My developers have coded a custom function which updates the line items in the Sales Order when it is saved, automatically changing prices and adding in required products depending on the Price Book chosen.

The issue we're encountering is we are unable to pull Sales Order details using the "getRecordById" function, for Sales Orders which have been rejected during the approval process. Any Sales Orders which haven't entered the approval process don't have this issue. When executing the following code:

return zoho.crm.getRecordById("Sales_Orders",SalesOrder_ID.toLong());

The script editor returns: 



Since it doesn't provide a reason for the failure, we are unable to determine why it's happening. The only clue is that this specifically happens for rejected Sales Orders.

Has anyone come across this issue before or would have any idea how to fix this?

Many Thanks,
Harry