Direkt zum Hauptbereich

Posts

Es werden Posts vom Februar, 2016 angezeigt.

Dynamic SOQL - Auswertung der Felder vom Related Object

Ein Custom Object ist mit dem Standard Account Object über ein Lookup-Feld verknüpft. Abhängig vom Country ISO Code auf dem Account wird die Sprache auf dem Projekt automatisch gesetzt. Da die oben beschriebene Konfiguration ein Teil eines Managed Packages ist, und die Country ISO Codes nicht in jeder Org konfiguriert sind, muss die Logik mit Einsatz von " dynamic soql " implementiert werden. Bei der Auswertung der ISO Codes erscheint die Fehlermeldung : Invalid field Account__r.BillingCountryCode for sf42_prfxpe__Project__c Lösung : zuerst Account über die Relation definieren, dann das entsprechende Feld auswerten sObject objRelAccount = objProject.getSObject('Account__r'); String sSoql = 'SELECT Id, Name, Account__c, Account__r. BillingCountryCode FROM Project__c'; for (Project__c p : Database.query(sSoql)){    sObject objRelAccount = objProject.getSObject('Account__r');    if(objRelAccount != null){        String sIsoCode = (String

Sortieren einer APEX Liste mit Wrapper Objekten einfach gemacht

Eine Visualforce Seite zeigt alle Feiertage in diesem Jahr. Jeder Feiertag entspricht einem Salesforce Objekt. Die Liste wird dynamisch aufgebaut und ist somit unsortiert. Der entsprechende Code sieht ungefähr so aus: public list<HOLIDAYS> getHoliday(){   list<HOLIDAYS> lstHolidays = new list<HOLIDAYS>();   ...   lstHolidays.add(new HOLIDAYS(obj, true));   ...   return lstHolidays; } /****************************** *** HOLIDAYS ******************************  public class HOLIDAYS{   public Holiday__c objHoliday{get; set;}   public String holidayName{get; set;}   public Id holidayId{get; set;}   public String holidayDate{get; set;}   public Decimal duration{get; set;}   public Boolean isChecked{get; set;}   public HOLIDAYS(Holiday__c h, Boolean isChecked){    this.objHoliday = h;    this.holidayName = h.Name;    this.holidayId = h.id;    this.holidayDate = h.Date__c.format();    this.duration = h.Duration__c;    this.isChecked = isChecked;   }  } Mit