0
  • There is a requirement to translate All the fields/ Objects/ Layouts that starts with a Particular Keyword say OK and replace it with DP.

  • Currently i'm using Schema.DescribeSObjectResult to extract fields/ Objects with that specified format and translating it then manually.

What is the shortest way to do the same ?

Code Snippet edited with current code:

Map<String,Schema.SObjectType> gd = Schema.getGlobalDescribe();

//List<Schema.SObjectType> objlist = new List<Schema.SObjectType>();
List<String> objList = new List<String>();
for(Schema.SObjectType obj :  gd.values() ){

  //system.debug(obj);

  Schema.DescribeSObjectResult objDesc =   obj.getDescribe();
  objList.add(objDesc.getLabel());   

  //system.debug(objList); 

}

system.debug(objList.size());

List<String> OKobjList = new List<String>();
for(String obj : objList){
  if(obj.contains('OK_')){ 
    OKobjList.add(obj);
  }
}

system.debug(OKobjList);
  • Can you post the snippet of how you are using Schema.DescribeSObjectResult – karthikselva Mar 1 '16 at 12:16
  • I've not proceeded much...just running this code snippet from the dev console..please find it in the updated questtion – user59759 Mar 1 '16 at 12:27
  • 2
    There is already a translation feature on the platform. Are you trying to do this to audit the location of all the labels? Or is this intended to translate on the fly at runtime? – pchittum Mar 1 '16 at 13:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.