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
SFDC Noob 1SFDC Noob 1 

Set partner on Opportunities

I need to set the Partner Users on previous Opportunities registered by that partner user. Only designation i have to connect the two is the LeadSource field on Opportunities that lists "Partner-XXXX", xxxx is the company name. There are over 10000 records that don't have a partner listed. What would be the best of doing this?
shashi lad 4shashi lad 4
If this is one time deal, you can create a small apex script and update those records. If needed more often or automate it, you can develop the similar logic in batch jobs.

eg.
list<oppotunity> olist = new list<oppotunity>();
for ( opportunity o : [select leadsource from opportunity where leadsource = null limit 9999]){
   logic ----  o.leadsource = 'Partner - '+ <companname field>
 olist.add(o);
}
update oList;


you can run this logic for few times if more than 9999 records because it will pickup new records everytime.

hope this helps.

thanks
shashi
shashi lad 4shashi lad 4
Run the above script from annonymous block. thanks
SFDC Noob 1SFDC Noob 1
The lead source fields are already populated, i need to add a related partner based on the lead source field.
And most likely be using it as a batch job.  

Thanks