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
timomertimomer 

inbound email, processed as different user + find that ID!

Hello,

 

I have an inbound email class that process the email and crates a new record in a custom object. This is working fine, but, I want the creator of the new object to be the sender of the email not the admin. Is there away to process the insert of the record as a different user in my class?

 

Also, another quick question... :smileywink:

I have the ID of an opportunity in the subject of he email, can anyone suggest the best way to grab the ID and get rid of the rest of the text? Currently I split the subject words into a array of strings, find the word that has the length of 15 and guess that's the ID, not sure if I can guarantee that the ID will always be a length of 15!? :smileytongue:

 

thanks!

Tim

werewolfwerewolf

To the first question, I believe the answer is no.

 

To the second question, you could run a regex on it using the Matcher class that looks for something like "006[0-9a-zA-Z]{12}"  -- that will match on an ID that starts with 006 (as all Opportunities do) and has 12 alpha chars after it.  Note that my regex syntax might not be exactly right here because it's off the top of my head, but it's probably pretty close.

timomertimomer

thanks werewolf, knowing all opps start with 006 was just what i needed.

 

Shame about the insert record as different user not possible, if anyone has any suggestions?