Need to calculate return date automatically

I have transdate field that is today date, and have to be return date field.

If a book is subscribed today user need to return the book with in 4 weeks if the pages is more than 1000, if it is less user need to return with in 2 weeks.

 

How can i write my method for above condition in table level

Thanks in advance..

  • In reply to Kranthi:

    i tried its not getting the max date in tobereturndate field
  • In reply to Sri Ranjani:

    So what does it returning? Try your code in a job or debug.
  • In reply to Kranthi:

    How to update the field in case:

    case fieldnum(AX_SubscriberLine,ToBereturnDate):
    select maxof(tobereturndate) from axsl where axsl.Sub_Id==this.Sub_Id;
    // select forupdate axsl where axsl.ToBereturnDate

    Maximum of each subscriber needs to set in the returndate field..
  • In reply to Sri Ranjani:

    Ilamvazhudhi Sri Ranjani
    Maximum of each subscriber needs to set in the returndate field..

    At what time it has to update or what action should update it?

  • In reply to Kranthi:

    It need to update the maximum of return date..

    If the subscriber subscribed 4 books, he can't come to return the single book alone so we need to assign the tobereturn date as max of 4books..
  • In reply to Sri Ranjani:

    That doesn't say when it has to update.
    Example - when creating a record, or modifying/updating any value in the current record?
  • In reply to Kranthi:

    wen i create a record..
  • In reply to Sri Ranjani:

    If i'm creating first subscribe details for an subscriber, it need to display the return date based on page...
    wen i create second record it will have some returndate, like tat each record will have returndate for tat subscribe..

    Wat i want to do is at the end i want all the tobereturndate to be modified to common date tat is max of returndate tat the subsciber subscribed..
  • In reply to Sri Ranjani:

    You have your code either in insert (before super()) or after having the value in Sub_Id,
    select maxof(tobereturndate) from axsl where axsl.Sub_Id==this.Sub_Id;
  • In reply to Kranthi:

    can you give me an example coding...
  • In reply to Sri Ranjani:

    override insert on table,

    select maxof(tobereturndate) from axsl where axsl.Sub_Id==this.Sub_Id;
    this.tobereturndate = axsl.tobereturndate;
    super();
  • In reply to Kranthi:

    I done this using modified field in line table by following code:

    case fieldnum(AX_TransactionLine,TransDate):
    select maxof(tobereturndate) from axtl where axtl.Trans_Id==this.Trans_Id;
    update_recordset axt2 setting tobereturndate = axtl.ToBereturnDate where axt2.Trans_Id==this.Trans_Id;
    break;

    Thank you all for helping..
Related
Recommended