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
Vaibhab ShahVaibhab Shah 

Configuration to populate one text field on Account object with one value of custom object

Hi,
I was asked in an interview the below question:
There is a custom object X and there is an Account Object.
Account object and X object do not have any relationship.

Whenever I will create an account record, I need to populate a text field with a value of X object on acccount object. This needs to be acheived using configuration and no customization.
Maharajan CMaharajan C
HI Vaibhab,

You can use the ( Process Builder + Visual Flow ) for this scenario. 

Thanks,
Maharajan.C

 
SwapnilGSwapnilG
You can use process builder to trigger the Flow. once the flow is triggered,you can query on X object and assign the value to the text field(Account field) as per your requirment.
Ajay K DubediAjay K Dubedi
Hi Vaibhab,

For you question, there are three solutions may be-

 1. Process Builder 
 2. Visual Flow 
 3. A trigger

Trigger may be a better solution. Please refer the code -
Let a text field on account-
Label - TextByObjX

and a record name on Object X is - XRecord


Trigger PopulateAccountField on account(After insert){
String str = '';
X__c xRec = [select name from X__c where name=:'XRecord'];

str = str + xRec.name;

account acc = [select TextByObjX from account where Id =:trigger.new];
acc.TextByObjX = str;
update acc;



}
The above short code will help you populate the text field on account with one record name on object X.



I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com