Problem with Delete action in Workflows / Rules

Problem with Delete action in Workflows / Rules

Hi,

When I delete an invoice, I'm trying to get his Sales Order Id to update a field on the Sales Order related to that invoice, but the fact is that the Delete action enables me to get that ID when I send an email or  via webhook, but not in a custom function.

There's any way to solve this? 
My code is like:

salesId = zoho.crm.getRecordById("Invoices", input.invoiceId);
id = salesId.get("Sales Order");
field = salesId.get("Billing");
updating = Map();
updating.put("Updated field", field);
update = zoho.crm.updateRecord("SalesOrders", id, updating);

When I try to get the id variable, returns null.

Any idea?
Thank you