2011-07-26 2 views
1

저는 IMAP4 수신함을 폴링하여 클라이언트의 이메일을 보내고이를 기반으로 Salesforce에 새로운 사례를 만드는 Windows 서비스를 작성하고 있습니다.Salesforce API : 전자 메일 참조 코드 ("[Ref : ... : Ref]")에서 사례를 식별하는 방법은 무엇입니까?

가끔 전자 메일이 해당 사례의 사례 참조 코드와 함께 제공됩니다. 예 : "[ref : 00FFwxyz.500FFJJS5 : ref]" 새로운 이메일을 만드는 대신 코드로 식별 된 기존 사례에 이러한 이메일을 할당하고 싶습니다.

내 질문 : ref 코드에서 고유 한 Case 식별자를 추출 할 수있는 확실한 공식이 있습니까? 그 반전을 수행하는 몇 가지 수식을 살펴 보았습니다.하지만 모두 같아 보이는 것 같습니다 : Blog post on KnowThyCloud.com, Force.com Discussion Board thread.

답변

2

알맞은 해결책을 찾았습니다. 나는 the post on KnowThyCloud.com 추측을 잘못했다. 올바른 컨텍스트에서 제대로 작동합니다.

제 솔루션은 "수식 (텍스트)"유형의 사례 레코드에 새 사용자 지정 필드를 만드는 것입니다. 이제 각 케이스 레코드에 대한 사용자 정의 필드의 값이 이메일에 참조 ID와 동일 내가 단순히 세일즈 포스 API로 쿼리 수

TRIM(" [ ref:" + LEFT($Organization.Id, 4) + RIGHT($Organization.Id, 4) +"."+ LEFT(Id, 4) + SUBSTITUTE(SUBSTITUTE(SUBSTITUTE(Id, RIGHT(Id, 4), ""), LEFT(Id, 4), ""), "0", "") + RIGHT(Id, 4) + ":ref ] ") 

: 필드의 값은 블로그 게시물에서 언급 한 공식이다 .

1

나는 urig의 솔루션을 구현했으며 잘 작동합니다.

다음은이 필드가없는 사례를 찾는 Apex 코드 솔루션입니다.

String emailSubject = 'FW: Re: RE: order 36000862A Case: 00028936 [ ref:00D7JFzw.5007Ju10k:ref ]'; 
String caseNumber = null; 
/* 
Extract the text after ref: and before the period. Could use this to locate the organization. 
In the text after the period and before the :ref split into a 4 digit number and remaining number. 
Insert 0's to get ref id. 
*/ 
String patternString = '.*ref:(.{8}).(.{4})(.+):ref.*'; 
Pattern thePattern = Pattern.compile(patternString); 
Matcher matcher = thePattern.matcher(emailSubject); 

if (matcher.matches()) { 
    String caseId = matcher.group(2) + '000000' + matcher.group(3); 
    Case[] matchingCases = [Select CaseNumber from Case where Id = :caseId]; 
    if(matchingCases.size() == 1) { 
     Case theCase = matchingCases[0]; 
     caseNumber = theCase.CaseNumber; 
    }  
} 
0

나는 underrscores을 포함하는 새 참조 문자열 (예를 들어, _00DC0PxQg._500C0KoOZS)을 지원하기 위해 위의 월의 코드를 수정했습니다.

String patternString = '.*ref:(.{11}).(.{5})(.+):ref.*'; 
Pattern thePattern = Pattern.compile(patternString); 
Matcher matcher = thePattern.matcher(emailSubject); 

if (matcher.matches()) { 
    String caseId = matcher.group(2) + '00000' + matcher.group(3); 
    system.debug('### '+caseId); 
    Case[] matchingCases = [Select CaseNumber from Case where Id = :caseId]; 
    if(matchingCases.size() == 1) { 
     Case theCase = matchingCases[0]; 
     caseNumber = theCase.CaseNumber; 
    }  
} 
관련 문제