[Salesforce]Apex時間遅延関数

     

  wait(10000);//Wait

    //Wait
    public static void wait(Integer millisec) {

        if(millisec == null || millisec < 0) {
            millisec = 0;
        }
        
        Long startTime = DateTime.now().getTime();
        Long finishTime = DateTime.now().getTime();
        while ((finishTime - startTime) < millisec) {
            //sleep for parameter x millisecs
            finishTime = DateTime.now().getTime();
        }
        // System.debug(‘>>> Done from ‘ + startTime + ‘ to ‘ + finishTime);
    }

[Salesforce]Get Object API reference name and Prefix from object label

    String searchObjLabelName = '取引先企業';
	String targetObjectName = '';

    Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
    for (String sKey : gd.keySet()) {
        Schema.DescribeSObjectResult targetObject = gd.get(sKey).getDescribe();
        if(targetObject.getLabel() == searchObjLabelName){
            targetObjectName = targetObject.getName();
			System.debug('targetObject.getLabel()----->targetObject.getName()::::::'+targetObject.getLabel()+'----->'+targetObject.getName());
        }
    }

    String objName = targetObjectName;	
    schema.sObjectType sObjType = Schema.getGlobalDescribe().get(objName);
    system.debug('prefix:'+(sObjType.getDescribe().getKeyPrefix()));

[Salesforce]オブジェクト表示ラベルからオブジェクトAPI参照名とPrefix取得

    String searchObjLabelName = '取引先企業';
	String targetObjectName = '';

    Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
    for (String sKey : gd.keySet()) {
        Schema.DescribeSObjectResult targetObject = gd.get(sKey).getDescribe();
        if(targetObject.getLabel() == searchObjLabelName){
            targetObjectName = targetObject.getName();
			System.debug('targetObject.getLabel()----->targetObject.getName()::::::'+targetObject.getLabel()+'----->'+targetObject.getName());
        }
    }

    String objName = targetObjectName;	
    schema.sObjectType sObjType = Schema.getGlobalDescribe().get(objName);
    system.debug('prefix:'+(sObjType.getDescribe().getKeyPrefix()));

[Salesforce][ENG]Get Prefix from ObjectName

Share to get the Prefix from Salesforce’s ObjectName.

Execute the following on the “Open Execute Anonymous Window” screen of the “Debug” tab on the development console screen.

    String objName ='Account';	
    schema.sObjectType sObjType = Schema.getGlobalDescribe().get(objName);
    system.debug('prefix:'+(sObjType.getDescribe().getKeyPrefix()));

The DebugLog result is below.

prefix:001

[Salesforce][ENG]Get object API reference name from object label

Here is an example of getting an object display label from an object API reference name.

    String searchObjLabelName = '取引先';
    Map<String, Schema.SObjectType> gd = Schema.getGlobalDescribe();
    for (String sKey : gd.keySet()) {
        Schema.DescribeSObjectResult targetObject = gd.get(sKey).getDescribe();
        if(targetObject.getLabel() == searchObjLabelName){
			System.debug('targetObject.getLabel()----->targetObject.getName()::::::'+targetObject.getLabel()+'----->'+targetObject.getName());
        }
    }