Date Modified by Assignee

Hi Team,

I would like to implement a Date_Modified_by_Assignee field in the Opportunity module that is automatically set to the current datetime when the record is updated but only if it is being updated by the user whom the record is assigned to.  Is there a simple way to do this?

Dave

  • You can create a simple date field with some sugar logic. This will compare the first and lastname with the current user's first and last name and if so it will return the current date. Otherwise it will return "". But ofcourse you can return whatever is in that field at that moment. I haven't tested it myself so you need to check if it actually works. 

    Fullscreen
    1
    2
    3
    4
    5
    6
    ifElse(
    equal(
    concat(currentUserField("first_name"),currentUserField("last_name")),
    concat(related($assigned_user_link,"first_name"),related($assigned_user_link,"last_name"))),
    now(),
    "")
    XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

    Another approach would be to create a logic hook that checks if the current user is the same as the $bean->assigned_user_id and if this is the case set the field value using php code.

  • Hi Jeroen.  Thanks so much.  That does appear to be the foundation of a viable solution.  I replaced the "" with a reference to the field itself which seems to work.

    There is one weird thing though.  I'm finding that the now() function is returning the time rounded up to the next 5 minutes.  Any idea why this would occur?

  • nope. I don't know what the cause of that would be

  • Ok.  I've just seen a time returned that's 14 minutes in the future.  I wonder if there's recursion or some other weird thing happening.  So I'm still without a usable solution.  Thanks anyway.

  • If on-prem check whether servers and local time is correct

    Best Regards,
    Dmytro Chupylka

    integroscrm.com
    We make work in Sugar CRM system faster, more convenient and efficient

  • No it's hosted.  Very weird that the now() function is returning a time that is ahead of what's shown in the Date Modified field.

  • If its on sugarcloud you could maybe create a ticket for that?