I am trying to re-use a class and run it in a job to prove something out. Here is the job code:
InventQuarantineOrder_Scrap scrap = new InventQuarantineOrder_Scrap();
;
scrap.parmInventQuarantineId('00016749_077');
scrap.parmScrapQty(360);
scrap.parmTransDate(Today());
scrap.run();
When I run this code, I get the error:
The cursor is invalid for instantiating recordViewCache
Researching this error led to me this link, which I tried to implement but I got syntax errors I'm not sure how to fix. I copied the class and created a new runOnServer method. But then a validate method doesn't work. So I modify the validate method to run on the server:
static server boolean validate()
{
InventQuarantineOrder inventQuarantineOrder = InventQuarantineOrder::find(inventQuarantineId);
;
....
}
Which gave me this error:
Variable inventQuarantineId has not been declared.
If I comment out the validate() call from the runOnServer method, I get the same error/problem with the inventQuarentineId variable not being declared (it's also used in the run method).
From here, I am not sure how to continue. What am I doing wrong? Is it possible to use these methods inside a server method? Another thing worth noting I think is that I think the job code actually worked, but it did throw 3 lines those "cursor is invalid for instantiating recordViewCache." info alerts.