Another Salesforce blog!!!

Salesforce, Apex

APEX

Get to Know the Salesforce APIs

Trailhead link The Salesforce API landscape is as vast as the ocean blue. That’s because Salesforce takes an API-first approach to building features on the Salesforce App Cloud. API first means building a robust API for a feature before focusing on designing its UI. This approach gives you, the Salesforce developer, flexibility to manipulate your […]

workbench object describe

/services/data/v37.0/sobjects/DC_Asset__c/describe Favorite

PageReference

public PageReference goBack() { PageReference pr = Page.DC_TableDetail; pr.getParameters().put(‘tblId’,tblId); pr.getParameters().put(‘colId’,colId); return pr; } <apex:repeat value=”{!Employees}” var=”e” id=”r”> <apex:commandLink value=”{!e.Name}” action=”{!clickOnName}”> <apex:param name=”eId” value=”{!e.Id}” assignTo=”{!empId}”/> </apex:commandLink> </apex:repeat> public Id empId{get; set;} public PageReference clickOnName() { system.debug(‘clickOnName//’ ); PageReference newPage = Page.NewEmployee; newPage.getParameters().put(’empId’, empId); return newPage.setRedirect(true); } Favorite

ApexPages currentPage()

String id = ApexPages.currentPage().getParameters().get(‘id’); if(id != ” || id != null) { //… } Favorite

capitalizing 1st character of each word in a string

String rep_name = ‘this is a test’; List<String> elems = rep_name.split(‘ ‘); rep_name = ”; for (String x : elems) { rep_name += x.substring(0,1).toUpperCase()+x.substring(1,x.length()) + ‘ ‘; } System.debug(‘>>>’+rep_name); Replace ‘_’ with space?: string sText = ‘ancestor_concept_id’; sText = sText.replaceAll( ‘_’, ‘ ‘); Favorite

Error, “List has no rows for assignment to SObject”

It would be safer to do the following: Player__c[] players = [SELECT Id from Player__c where Name = :username]; if (players.size() > 0) p = players[0].Id; Favorite

lazyload loading

public Employee__c[] employees { get { return employees == null ? employees = [some soql]; : employees; } set; } Favorite

Converting GMT into Locale Users Time Zone

String timeZone = UserInfo.getTimeZone().getID(); Datetime dateGMT=System.now();// here you can user your dates e.g. createddate Datetime d1=Datetime.valueOf(dateGMT); string s1=d1.format(); System.debug(‘@@@@@@@@@@@’+s1); Favorite

TimeZone with Visualforce page date/time

Some months ago I had a project where I needed to show what date and time an order was processed in Eastern regardless of who submitted the order and their related timezone. Google will quickly show the light for how to display date/time using the timezone set on the user profile or GMT. So the […]

Counting how many fields I have available on an object

integer FieldCount = account.sObjectType.getDescribe().fields.getMap().size(); system.debug(‘//’+ FieldCount); Favorite

Previous Posts Next posts