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
Aryan_SFDCAryan_SFDC 

Populated default values while creating the contact

Hi,

I am trying to auto populate default fields while creating the contact.
e.g Mailing region, country.
When users select new contact from account then default values should be populated.
also users should be able to chage the picklist values if they want.
Any suggestions how can I implement this logic.
I want to implement it for 2 users.
Thanks in advance
Best Answer chosen by Aryan_SFDC
Aryan_SFDCAryan_SFDC
I found the solution.
1.Populated default values while creating the contact:
I have created a custom action(Quick contact) and edited the layout with the fields I want.
and setup Predefined Field Values there.
added this custom action the 2 required page layouts.

2.To make custom action user specific:
Open account record page.
click on settings icon and edit page.
click on custom action section.
Using dynamic actions I have made this changes specific to 2 users.

All Answers

CharuDuttCharuDutt
Hii Nagesh
Try Below Trigger
trigger ContactTrigger on Contact (Before Insert) {
  for(Contact Con : trigger.new){
  Con.MailingCity = 'Texas';
  Con.MailingCountry = 'USA';
 }
}
Please Mark It As Best Answer If It Helps
Thank You! 
Naveen KNNaveen KN
If Mailing Region and Country are picklist fields then you can directly do it in the object level > picklist field > select the default value for each picklist
Suraj Tripathi 47Suraj Tripathi 47
Hii Nagesh,

please try below code
 
trigger ContactTrigger on Contact (Before Insert) {
  for(Contact ConObj : trigger.new){
if(ConObj.MailingCity == null || ConObj.MailingCountry == null) // here you can check user name or profile name    also 
  Con.MailingCity = 'Delhi';
  Con.MailingCountry = 'India';
 }
}


If you find your Solution then mark this as the best answer.

Thank you!
Regards,
Suraj Tripathi  
Aryan_SFDCAryan_SFDC
Hi All,

Thanks for you suggestions.
The idea is to make conact creation easy by populating default field while creating the 
contact(not to insert default values after creation of the record).
Steps:
1.Open account.
2.go to related list named as contact.
3.Click on new contact.
4.On this screen,field should be populated by default while creating the contact.
Account name = It will display account name of related account.
mailing country(text field)= India (this should be seen to user by default but if he want then he should able to enter the another country name)
Mailing region(picklist) = Asia pacific(this should be seen to user by default but if he want then he should able to select another picklist value)
Language(picklist) = English (this should be seen to user by default but if he want then he should able to select another picklist value)
Aryan_SFDCAryan_SFDC
I found the solution.
1.Populated default values while creating the contact:
I have created a custom action(Quick contact) and edited the layout with the fields I want.
and setup Predefined Field Values there.
added this custom action the 2 required page layouts.

2.To make custom action user specific:
Open account record page.
click on settings icon and edit page.
click on custom action section.
Using dynamic actions I have made this changes specific to 2 users.
This was selected as the best answer