0

我是 SFDC 的新手,我有一个程序,我在其中传递值,我需要将这些值与存在或不存在的自定义对象字段进行比较。

这是我的代码,

public class CheckUtility {

    public static ID determineFeature(ID defaultPersonaID, String Email, String Industry, String Title, Decimal Revenue, Integer EmployeeCount) {

        ID fetrID = defaultFeatureID;
        String emailDomain = Email.split('@').get(1);           
        Feature__c[] features = new Feature__c[]{};
        features = [Select id, Industries__c, Title_Tags__c, Email_Domains__c, Company_Revenue_From__c, Company_Revenue_To__c, Employee_Count_From__c, Employee_Count_To__c FROM Feature__c ORDER BY lastModifiedDate DESC];
        Integer industriesFound = 0;
        for (feature__c p: features) {
     // checking if there is a matching feature based on email    
        System.debug('Email Domains = ' + p.email_domains__c);        
             if (p.Email_Domains__c != null &&     
        p.Email_Domains__c.contains(emailDomain)) {
                 fetrID = p.ID;
                break;
             }

             if(p.Industries__c != null){ 
  //I am stuck compare the industry is present or not in the p.Industries__c (picklistdatatype)

               System.debug('Industries' + p.Industries__c);        
                 fetrID = p.ID;
                break;
             }
        }                

        return fetrID;      
    }      
}

不,我有 Feature__c 是一个自定义对象。Feature__c.Industries__c 自定义字段可以有一个值或多个值。

例如:Feature__c(对象)

id                | Industries__c
a010b00000eERj4   | technology
a010b00000eEYu4   | finance, biotechology
a010b00000eHJj8   | chemical, healthcare

我想检查 Industry (通过在 determineFeature 中传递的值)是否等于 Feature__c 中有多少 Industries__c 并发送他们的 fetrID 作为响应。

4

2 回答 2

0

我的理解是我在下面实现的。如果有任何疑问或误解问题,请告诉我。

使用您需要在自定义对象中进行比较的值。

public class custom_ctrl{

public Feature__c fetur {get;set;}
public String comparvalue {get;set;}

public custom_ctrl()
{
  fetur =new Feature__c ();

  fetur=[select Name,Email from feature__c where Name=:comparvalue ]

  if(comparvalue == fetur.Name)      
 {
     //action
 }
 else
 {
     //else action
 }

}
于 2018-11-13T14:44:33.163 回答
0

后端的多选选项列表只是一个带有分号分隔值的文本字段,因此您可以执行以下操作:

Set<String> industries = new Set<String>()
industries.addAll(String.split(p.Industries__c, ';')); 
if (industries.contains(Industry)) { ... }

顺便说一句,这是多余的:

Feature__c[] features = new Feature__c[]{};
features = [Select id, (...)

因为 [SELECT] 总是返回列表,即使它是空的。

于 2018-09-23T19:10:59.340 回答