• Mark Neill 13
  • NEWBIE
  • 5 Points
  • Member since 2018

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 1
    Replies
I receive a feed of employees I load into a custom object. It has the employee number from another system.

I need to be able to update another  LOOKUP field  (relationsjhip is the User table) based on the employee number the user enters.

The employee number is a field in the USER table  ..so I need to match on it and return the userID to the empty lookup field

Can this be done with a workflow or process builder.  

Example:

Text fied value  Employee Number = 50410 
Need to relate that value to the user.employeeID
and  return the user.ID to a seperate lookup field  
 
Hi All,

Hope you could assist me modifying a code or adding a new one. I currently have email services that creates an Opportunity.  I am not really a coder, I am just looking around how to get this done.

My goal is that when user send an email from that Opportunity record (generated from Email services) and customer replies back (with threadId generated initially), the response of the customer should be attached to existing Opportunity. How can I achieve that? Should I attach it to existing code that I have?

Here is my existing Code that generates Opportunity record:
global class OpportunityCreation implements Messaging.InboundEmailHandler {

  global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email,
    Messaging.InboundEnvelope envelope) {

     Messaging.InboundEmailResult result = new Messaging.InboundEmailresult();
     
     String fName = email.fromname.substring(0,email.fromname.indexOf(' '));
     String lName = email.fromname.substring(email.fromname.indexOf(' '));
     
     Contact vCon;
     for(Contact c: [Select Id, Name, Email, AccountId From Contact Where Email = :email.fromAddress Limit 1])
         vCon = c;
     if(vCon == null)
     {
        vCon = new Contact(
        FirstName = fName,
        LastName =  lName,
        Email = email.fromAddress);
        insert vCon;
     }   
     
     Opportunity opportunity = new Opportunity();
     opportunity.Name = email.Subject;
     opportunity.StageName = 'Prospecting';
     opportunity.CloseDate = Date.today();
     opportunity.Email_Body__c = email.plainTextBody;
     opportunity.Contact_Name__c = vCon.Id;
     opportunity.AccountId = vCon.AccountId;
     insert opportunity;
    
       System.debug('====> Created opportunity '+opportunity.Id);
       
      
if (email.binaryAttachments != null && email.binaryAttachments.size() > 0) {
      for (integer i = 0 ; i < email.binaryAttachments.size() ; i++) {
        Attachment attachment = new Attachment();
        // attach to the newly created opportunity record
        attachment.ParentId = opportunity.Id;
        attachment.Name = email.binaryAttachments[i].filename;
        attachment.Body = email.binaryAttachments[i].body;
        insert attachment;
      }
    }
  
    return result;

  }

}


Thank you in advance.