function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Nicole Chang_Nicole Chang_ 

Edit the data type of a standard Event field

Hello everyone,

There's standard field on Event "WhatId", data type is Lookup (Contract,Account,Opportunity,Lead,Contact,....) 
Is there anyway to change data type to Lookup only to those objects (Account,Opportunity,Lead,Contact) & remove the rest please?

Thank you so much!
 
Best Answer chosen by Nicole Chang_
SwethaSwetha (Salesforce Developers) 
The prefixes are
Account =001,
Opportunity=006,
Lead=00Q,
Contact=003,
Contract= 800

See commonly used object's prefixes list on https://www.salesforceben.com/salesforce-object-key-prefix-list/
Detailed prefixes list: https://help.salesforce.com/s/articleView?id=000325244&type=1

Hope this helps. Thank you

All Answers

SwethaSwetha (Salesforce Developers) 
Hi Nicole,
We cannot change the standard field functionality. If we want a particular lookup only we have to write a validation rule on that object such that starting id should be 001 or 005 something related to it.

Hope this helps. Thank you.
Nicole Chang_Nicole Chang_
Thanks @Swetha. Could you please be more specific on validation rule please? I am not so much of developer myself (sorry)
From what Ive been searching so far, looks like we can create a custom field also?  
SwethaSwetha (Salesforce Developers) 
Try
AND(NOT(BEGINS ( WhatId , ‘001’)),NOT(BEGINS ( WhatId , ‘003’)),NOT(BEGINS ( WhatId , ‘00Q’)),NOT(BEGINS ( WhatId , ‘006’)))

This is validation rule on Event object that will only allow if whatid is Acount,Contact,Opportunity and Lead

If this information helps, please mark the answer as best. Thank you
Nicole Chang_Nicole Chang_
thanks @swetha. 001; 003 refers to the order of Contract,Account,Opportunity,Lead,Contact? as in 001 = Contract, 002= Account,...?
SwethaSwetha (Salesforce Developers) 
The prefixes are
Account =001,
Opportunity=006,
Lead=00Q,
Contact=003,
Contract= 800

See commonly used object's prefixes list on https://www.salesforceben.com/salesforce-object-key-prefix-list/
Detailed prefixes list: https://help.salesforce.com/s/articleView?id=000325244&type=1

Hope this helps. Thank you
This was selected as the best answer
Nicole Chang_Nicole Chang_
ahhhh ok!!! now its clear for me, let me try! thank you sooo muchh!!
Nicole Chang_Nicole Chang_
also, this looks like Prefix for standard object, do custom objects have prefix code also please? 
SwethaSwetha (Salesforce Developers) 
That is correct. Even custom objects have a prefix. You can identify this from the URL when you open your custom object's record.

Example: https://cti712-dev-ed.lightning.force.com/lightning/r/car__c/a2i6F000007jJJCQA2/view

a2i is my custom object(car__c)'s prefix for the record Id a2i6F000007jJJCQA2
Nicole Chang_Nicole Chang_
standard object works just fine, tried prefix with custom object, but so far did not work as expected, I can still relate event to that custom object