Field that auto prints date when another field is updated

Trying to created a Primary Contact field on our Accounts / Contacts modules.

The field has a simple Yes/No Drop down... 

I would like another field next to it (Primary Contact updated) that automatically puts the date in if someone chooses Yes for the primary Contact field. 

this is what i have so far but its just not right

isInList(related($contactlist_c,"primary_contact_c"),createList("Yes"))now(),date("null"))

so if primary_contact_c = Yes, then input date, ifelse then null

can someone help me get the right formula for this. 

Parents
  • Assuming your contacts are related to just ONE Account, not multiple Accounts.

    I would add an audited field on Contacts called "Primary Contact".

    Also add that flag to your list view and search results so that users can see/search-for the "Primary Contact" when deciding which contact to use on things like Opportunities etc. 

    Option 1.

    Add a check in the Contact module record and create view controllers to see if the "Primary Contact" box is checked, if so see if the Account related to that Contact has another Primary Contact. If the Account already has a Primary show a Confirmation Alert so the user knows they will be unsetting that Primary to make this the Primary.

    Then add a Logic Hook that, when the record is saved, checks if the Primary Contact changed from unchecked to checked, in which case find any Primary Contact on the Account and unset that one. (I am assuming you don't want multiple Primary Contacts on an Account as that would defeat the purpose). Make sure your logic hook excludes the Contact you just selected as your primary when looking at related Contacts.

    Option 2.

    You could make that checkbox editable ONLY in the subpanel view of the Account (by forcing it to read-only on all the other views: create, record, list, and leave it out of any other Contacts subpanel views that are not on Accounts).

    This forces the user to see all the Contacts on the Account and pick the Primary.

    In your subpanel view controller you would take care to uncheck any other Contact that was primary.

    The downside of this latter approach is that when someone creates a new Contact and relates it to an Account they can't mark the Contact as primary during the creation, they have to go to the Account after the Contact is created and mark it Primary from there. It also means that any API that creates a Contact with the Primary checked will NOT unset the flag.

    Overall, I would say Option 1 is probably your safest bet.

    As Dmytro said, the audit on the "Primary Contact" will take care of stamping changes, and in this example will mark both non-primary to primary on your current Contact and primary to non-primary on the Contact that used to be Primary.

    If you want, you can also add a couple of read-only fields for Primary Contact last changed, and Primary Contact changed by. Those could easily be populated by the logic hook (in Option 1) or controller (in Option 2). But you need to be sure to update both them in both the new and old primary Contact record.

    FrancescaS

Reply
  • Assuming your contacts are related to just ONE Account, not multiple Accounts.

    I would add an audited field on Contacts called "Primary Contact".

    Also add that flag to your list view and search results so that users can see/search-for the "Primary Contact" when deciding which contact to use on things like Opportunities etc. 

    Option 1.

    Add a check in the Contact module record and create view controllers to see if the "Primary Contact" box is checked, if so see if the Account related to that Contact has another Primary Contact. If the Account already has a Primary show a Confirmation Alert so the user knows they will be unsetting that Primary to make this the Primary.

    Then add a Logic Hook that, when the record is saved, checks if the Primary Contact changed from unchecked to checked, in which case find any Primary Contact on the Account and unset that one. (I am assuming you don't want multiple Primary Contacts on an Account as that would defeat the purpose). Make sure your logic hook excludes the Contact you just selected as your primary when looking at related Contacts.

    Option 2.

    You could make that checkbox editable ONLY in the subpanel view of the Account (by forcing it to read-only on all the other views: create, record, list, and leave it out of any other Contacts subpanel views that are not on Accounts).

    This forces the user to see all the Contacts on the Account and pick the Primary.

    In your subpanel view controller you would take care to uncheck any other Contact that was primary.

    The downside of this latter approach is that when someone creates a new Contact and relates it to an Account they can't mark the Contact as primary during the creation, they have to go to the Account after the Contact is created and mark it Primary from there. It also means that any API that creates a Contact with the Primary checked will NOT unset the flag.

    Overall, I would say Option 1 is probably your safest bet.

    As Dmytro said, the audit on the "Primary Contact" will take care of stamping changes, and in this example will mark both non-primary to primary on your current Contact and primary to non-primary on the Contact that used to be Primary.

    If you want, you can also add a couple of read-only fields for Primary Contact last changed, and Primary Contact changed by. Those could easily be populated by the logic hook (in Option 1) or controller (in Option 2). But you need to be sure to update both them in both the new and old primary Contact record.

    FrancescaS

Children
No Data