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..

  • if (pages > 1000)
    returnDate = transDate + (4*7);
    else
    returnDate = transDate + (2*7)
  • In reply to Kranthi:

    No its not getting the return date..
    I write in validate write method as
    public boolean validateWrite()
    {
    boolean ret;
    AX_BookMaster axb;
    AX_SubscriberLine axs;
    ;
    ret = super();
    if(axb.Pages>'1000')
    this.TobeReturnDate= axs.TransDate+(4*7);
    else
    this.TobeReturnDate=axs.TransDate+(2*7);
    return ret;
    }


    when I gave the transdate it is displaying as 15/11/90
  • In reply to Ilamvazhudhi Sri Ranjani:

    You shouldn't be doing it in validateWrite() method.
    Override modified field on table and write a case for TransDate
    if(axb.Pages>'1000')
    this.TobeReturnDate= this.TransDate+(4*7);
    else
    this.TobeReturnDate=this.TransDate+(2*7);

    You are not selecting axb record. So it will always goes to else, you need to find the axb record before doing it.
  • In reply to Kranthi:

    i already wrote one modified field method as
    public void modifiedField(fieldId _fieldId)
    {
    AX_SubscriberLine axsl;
    ;
    super(_fieldId);
    if(_fieldId==fieldnum(AX_Transaction,Book_Id))
    {
    select axsl where axsl.Book_Id==this.Book_Id;
    this.Sub_Id=axsl.Sub_Id;
    this.TransDate=axsl.TransDate;
    }
    }

    how can i override again in modifield field method.
  • In reply to Ilamvazhudhi Sri Ranjani:

    check the example from standard table like CustTable.
  • In reply to Kunal:

    ok!
  • In reply to Ilamvazhudhi Sri Ranjani:

    Then you don't have to override it. Modify it.
    switch(_fieldId)
    {
    case fieldNum(fieldnum(AX_Transaction,Book_Id)):
    select axsl where axsl.Book_Id==this.Book_Id;
    this.Sub_Id=axsl.Sub_Id;
    this.TransDate=axsl.TransDate;

    break;
    case fieldNum(AX_Transaction, TransDate):
    // place your logic here
    break;
    }
  • In reply to Kranthi:

    public void modifiedField(fieldId _fieldId)
    {
    AX_SubscriberLine axsl;
    AX_BookMaster axb;
    ;
    super(_fieldId);
    switch(_fieldId)
    {
    case fieldnum(AX_Transaction,Book_Id):
    select axsl where axsl.Book_Id==this.Book_Id;
    this.Sub_Id=axsl.Sub_Id;
    this.TransDate=axsl.TransDate;

    break;
    case fieldNum(AX_Transaction, ToBeReturnDate):
    if(axb.Pages>'1000')
    this.TobeReturnDate= axsl.TransDate+(4*7);
    else
    this.TobeReturnDate=axsl.TransDate+(2*7);

    break;
    }
    /*
    if(_fieldId==fieldnum(AX_Transaction,Book_Id))
    {
    select axsl where axsl.Book_Id==this.Book_Id;
    this.Sub_Id=axsl.Sub_Id;
    this.TransDate=axsl.TransDate;
    }*/
    }

    Again its not calculating:(((
  • In reply to Ilamvazhudhi Sri Ranjani:

    Ilamvazhudhi Sri Ranjani
    case fieldNum(AX_Transaction, ToBeReturnDate):

    case fieldNum(AX_Transaction, TransDate)

    Ilamvazhudhi Sri Ranjani
    if(axb.Pages>'1000')

    You are not selecting any record - axb

  • In reply to Kranthi:

    how to do tat??
  • In reply to Ilamvazhudhi Sri Ranjani:

    You should be knowing the relation between current table and AX_BookMaster
    Example - select firstonly pages from axb where axb.Book_Id == this.Book_Id;
  • In reply to Kranthi:

    stil i cant get the return date, Kranthi:(
  • In reply to Ilamvazhudhi Sri Ranjani:

    I have following tables : AX_BookMaster with book name, id, author name, pages, isbn num
  • In reply to Ilamvazhudhi Sri Ranjani:

    AX_Subscriber table with subscriber id, name and address
    I have the subscriberlines in another table with fields SubscriberId,BookId and transdate as today date.

    I create relation in subscriberline table to bookid and subscriber id.


    Now I created another table as Transaction table to mention the tobereturndate of the book and status as checkin, checkout..
    When the book is subscribed it need to change the status as checkout and when it is returned it need to change as checkin.
  • In reply to Ilamvazhudhi Sri Ranjani:

    in transaction table i tried to write the modified field coding as you mentioned:
    public void modifiedField(fieldId _fieldId)
    {
    AX_SubscriberLine axsl;
    AX_BookMaster axb;
    ;
    super(_fieldId);
    switch(_fieldId)
    {
    case fieldnum(AX_Transaction,Book_Id):
    select axsl where axsl.Book_Id==this.Book_Id;
    this.Sub_Id=axsl.Sub_Id;
    this.TransDate=axsl.TransDate;
    break;

    case fieldNum(AX_Transaction, ToBeReturnDate):
    while select pages from axb where axb.Book_Id==this.Book_Id
    {
    if(axb.Pages>'1000')
    this.TobeReturnDate= axsl.TransDate+(4*7);
    else
    this.TobeReturnDate=axsl.TransDate+(2*7);
    }
    break;
    }
    /*
    if(_fieldId==fieldnum(AX_Transaction,Book_Id))
    {
    select axsl where axsl.Book_Id==this.Book_Id;
    this.Sub_Id=axsl.Sub_Id;
    this.TransDate=axsl.TransDate;
    }*/
    }

    but it is not getting the return date please give me the exact coding..
Related
Recommended