Days auto update in field

HI ,

I am working on sales and marketing module where i have added two extra fields BIdclosingdays and BidremainingDays , Bidclosingdyas should be chosen by user but bidremainingdays should be calculated from system date like if i set bid closing date 31/10/2013 then bid remaining days from today(30-10-2013) should be 1 only , but its not updating in table same days are showing from the date of creation of Opportunity.

ttsbegin;

if (today()<=this.BidClosingDate)

{

this.BiddingRemainingDays=real2int(abs(this.BidClosingDate-today()));

}

else

{

this.BiddingRemainingDays=0;

Here i tried Today() function but tried with systemgetdate() function too.

Please suggest me a answer how it will automatically be updated with system date.

Thanks

Regards

Nakul

Hi Nakul,

Where are you writing your code, which method ?

Hi abhijit,

I am writing code in update method.

Is your code before super()? If not, you just set values to the table buffer, but the buffer doesn’t get saved to database.

By the way, I would simplify your code to this.BiddingRemainingDays = max(0, this.BidClosingDate - systemDateGet());

Thank you martin , but my code is before super still its not updating same value is reflecting in Bidremainingdays i made a opportunity with bidclosing date yesterday for bidclosingdate(usr) today its reflecting same like yesterday but system date has changed …

Hey martin,

if i am writing your code in insert method then its working but if m writing it in update its always showing “0”.

You should find out why it’s 0. Use the debugger to see what exactly is happening.

update method is called only when system defined fields are modifying i.e opening date and closing date , but insert method is called every single time in this case so what should be done next .,please suggest a solution.

If you’re always creating a new record and not updating an existing one, update() is obviously not called. I can’t tell you more because I have no idea about either what you developed or what you wanted to develop. You would have to provide more information.

At least you now know that you were solving a wrong problem - the calculation works but it’s not called at the time when you expect it to be called.

Thank you martin for your kind reply :slight_smile: , simply i want a functionality that calculates the remaining days from my decided days and should automatically update the days from current date , for e.g if my closing date is after 4 days then today it must show days remaining=4 , tomorrow it should show

days remaining=3 and after that 2 and so on.

Problem solved by using AOSValidateread and reread methods…