Schedule Functions

Has anyone created a function that they can schedule. I would like to see an example if that is possible. My business case that is requiring me to do this is for a RMAs.

We would like to close out RMA that have not had any receipts in 30 days since the RMA was created.


Yes, I have created and tested. Its similar to any other BPMs except few syntax like calling BO are different. I have done to replace Service Connect flow to reject POs older than 2 days. Thanks to Jose for posting BO calling function code.

DateTime lCutOffDate = DateTime.Today.AddDays(-2) ;
using (System.Transactions.TransactionScope transactionScope = IceDataContext.CreateDefaultTransactionScope())
foreach (var PH in (from POHeader_Row in Db.POHeader.With(LockHint.NoLock)
join PurAuth_Row in Db.PurAuth.With(LockHint.NoLock) on new{POHeader_Row.Company, POHeader_Row.BuyerID} equals new {PurAuth_Row.Company, PurAuth_Row.BuyerID}
where (string.Compare(POHeader_Row.Company, Session.CompanyID , true) == 0 ) && POHeader_Row.OpenOrder == true &&
string.Compare(POHeader_Row.ApprovalStatus, ā€œPā€, true) == 0 && POHeader_Row.UserDate1 <= lCutOffDate && string.Compare(PurAuth_Row.DcdUserID, Session.UserID, true) == 0
select new {POHeader_Row.Company, POHeader_Row.PONum}))

CallService<Erp.Contracts.POApvMsgSvcContract>( bo =>
var POApvMsgTS = new Erp.Tablesets.POApvMsgTableset();
POApvMsgTS = bo.GetByID(PH.PONum);

                            var currentRow2 = POApvMsgTS.POApvMsg[0];
                            var addedRow2 = POApvMsgTS.POApvMsg.NewRow();
                            BufferCopy.CopyExceptFor(currentRow2, addedRow2, "");
                            currentRow2.RowMod = "U" ;
                            currentRow2.ApproverResponse = "REJECTED" ;
                            POApvMsgTS.POApvMsg.Add(addedRow2) ;
                            var POAPVDs = POApvMsgTS;
                            bo.Update(ref POAPVDs) ;
                        catch (Exception ex)
                                 "PO esclation reject error email alert. PO" + PH.PONum.ToString()  ,
                                 "Please find the details of error during PO esclation reject process. Please take appropriate action." +  "\n\n" +  ex.ToString(),