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
Steve ConnellySteve Connelly 

how do i search for a custom object record with the same field value as in an opportunity custom field?

Good afternoon all,

I am new to programming and could use a little help with something.

I have a trigger where I need to find and use a custom object record that has the same field value as the opp that fires the trigger.

The Opp have a custom formula field that shows the quarter when the opp was opened. (Q2-2019).

I need to use that value to find a record in a custom object that has that same value in one of it's field.

Note, there will never be more than one match.

But I have no idea how to do that.

Can anyone offer me some suggestions?

Thanks much,
Steve
Best Answer chosen by Steve Connelly
Ashima nidhiAshima nidhi
@Steve to search a record we use query (SOQL) for example : 
select APINameofFieldtoselect from your customobjectAPIname where fieldapiname = 'Valuetomatch'

select id from lead where abc__c ='I am here';

Check this trail  for better understanding :https://trailhead.salesforce.com/en/content/learn/modules/apex_database/apex_database_soql
For Trigger : https://trailhead.salesforce.com/en/content/learn/modules/apex_triggers

Hope above information was helpful.

Please mark as Best Answer so that it can help others in the future.