Post

1 follower Follow
0
Avatar

Usage of Now() or Today()

Hi,

I created a custom field at "Task" Entity level. Field has to update based on Completion date of task (Custom field).

Here I used DateDiff() function to achieve get difference between two dates. Function is working as excepted when i use two date fields.

But When I use DateDiff using one field and Now(). It is showing error message as "Invalid function Now() usage in current context"

My Expression

:DateDiff($DueDate ,Now())

Can you please help me out in this.

Import from old forum Answered

Please sign in to leave a comment.

6 comments

0
Avatar

Hi Uday,

Now()  function cannot be used in a formula of custom fields (otherwise, they will have to be calculated every passing second...)

Instead of having a formula based field, I suggest you accomplish that via a workflow rule that will be triggered when a task is completed.

Makes sense?

Rachel

Import from old forum 0 votes
Comment actions Permalink
0
Avatar

I think work flow rule doesn`t work out for me in this case.

Here I am creating a custom status based on due date (Standard field of clarizen) and Actual complete date (Custom field).

I am setting status as follows:

if(Not(IsNull($DueDate)) && Not(IsNull($C_ActualCompleteDate)),

    if(Truncate(DateDiff($DueDate ,$C_ActualCompleteDate,"d")) = 0,

        "Completed"

        ,

        if(Truncate(DateDiff($DueDate ,$C_ActualCompleteDate,"d")) < 0,

        "Delayed"

        ,

        "Early Complete"

    )

    ),

        if(Truncate(DateDiff($DueDate ,Today(),"d")) < 0,

        "Problem"

        ,

        "On Track"

    ))

Import from old forum 0 votes
Comment actions Permalink
0
Avatar

Hi Uday,

Thanks for clarifying. The use case is clear now. In such a case you need that to be scheduled workflow rule that will run daily, rather than a workflow rule.

Thanks

Rachel

Import from old forum 0 votes
Comment actions Permalink
0
Avatar

Hi Rachel,

Thanks for your reply. I got  a thought to get today`s date in custom filed. I want to create a custom filed with name "DateToday"  and i want to update the date based on scheduled work flow rule and I will use this field in custom field in my expression.

Let me know your thoughts on it. Will it work?

--

Thanks

Uday

Import from old forum 0 votes
Comment actions Permalink
0
Avatar

Hi Uday,

yes. 

This will work ! all you have to do is update this field daily and then the other field could be regular formula based field.

Regards

Rachel

Import from old forum 0 votes
Comment actions Permalink