Cant get a schedule function to run correctly

Cant get a schedule function to run correctly

Hello I have a custom function that I have written and I know works as I have tested it in a workflow, I need the function to run every morning at 6am so have created a schedule but when I create the function in the schedule I cannot associate the argument with the correct module to get the ID.
the module is called Sales_Contract. my code is attached below.

any help would be great thanks.
Cheers Kevin
  1. ScDetails = zoho.crm.getRecordById("Sales_Contract",salescontractId.toLong());
  2. info ScDetails;
  3. date1 = ifnull(ScDetails.get("Start_Date"),"");
  4. date2 = ifnull(ScDetails.get("End_Date"),"");
  5. currentDate = today;
  6. info date1;
  7. info date2;
  8. info currentDate;
  9. //if(date1 != "")
  10. if(currentDate > date1.toDate() && currentDate < date2.toDate())
  11. {
  12. Status1 = "Open";
  13. mp = Map();
  14. mp.put("Status",Status1);
  15. updateRecord = zoho.crm.updateRecord("Sales_Contract",salescontractId.toLong(),mp);
  16. info mp;
  17. info updateRecord;
  18. }
  19. else if(currentDate > date2.toDate())
  20. {
  21. Status2 = "Closed";
  22. mp = Map();
  23. mp.put("Status",Status2);
  24. updateRecord = zoho.crm.updateRecord("Sales_Contract",salescontractId.toLong(),mp);
  25. info mp;
  26. info updateRecord;
  27. }
  28. else if(currentDate < date1.toDate())
  29. {
  30. Status3 = "Awaiting Start";
  31. mp = Map();
  32. mp.put("Status",Status3);
  33. updateRecord = zoho.crm.updateRecord("Sales_Contract",salescontractId.toLong(),mp);
  34. info mp;
  35. info updateRecord;
  36. }