Another Salesforce blog!!!

Salesforce, Apex

August, 2016

Redirecting BACK to the original page

VFP: <apex:commandButton action=”{!backReturn}” value=”Back”/> Controller: public with sharing class SaveAndReturnController { private ApexPages.StandardController controller; public SaveAndReturnController(ApexPages.StandardController controller) { this.controller = controller; } public PageReference backReturn() { PageReference cancel = controller.cancel(); //controller.save(); return cancel; } } Favorite

Difference between sets

Set<String> seta = new Set<String>(); seta.add(‘a’); seta.add(‘b’); seta.add(‘c’); Set<String> setb = new Set<String>(); setb.add(‘b’); setb.add(‘c’); setb.add(‘d’); Set<String> result = seta.clone(); result.removeall(setb); setb.removeall(seta); result.addall(setb); system.debug(‘—————————>’+result); //output : —————————>{a, d} Favorite

Back Button in Visualforce page

<apex:commandButton value=”Back” action=”{!backMethod}”/> public pagereference backMethod() { Pagereference pg = new Pagereference(‘/apex/NameOfPage); pg.setRedirect(true); return pg; } Favorite

Awesome CSS icons

Note: it is not possible to use :before or :after pseudo content on ‘INPUT’ elements, however if you instead use LABEL, it will work as desired. Below is a Font Awesome cheat sheet of all the content values for each icon: <link href=’//netdna.bootstrapcdn.com/font-awesome/4.0.3/css/font-awesome.css’ rel=’stylesheet’/> fa-glass “\f000” fa-music “\f001” fa-search “\f002” fa-envelope-o “\f003” fa-heart “\f004” fa-star […]

isNotEmpty() Vs. isNotBlank()

Source Link isNotEmpty() is used to find if the String is not empty and not null. isNotBlank() takes it a step forward. It not only checks if the String is not empty and not null, but also checks if it is not only a whitespace string. isNotEmpty .isNotEmpty(null) = false .isNotEmpty(“”) = false .isNotEmpty(” “) […]

Checkbox required in Salesforce

How can you make the checkbox be required in the standard Salesforce page? by default you can’t make the checkbox required in the page layout this is something you have to write custom validations in order to fulfill this check, you can do this by going to Validation of that object: IF(fieldname__c , FALSE, TRUE) […]

OFFSET IN SOQL QUERY

OFFSET is used to specify the starting row offset into the result set returned by your query. Using OFFSET is helpful for paging into large result sets, in scenarios where you need to quickly jump to a particular subset of the entire results. As the offset calculation is done on the server and only the […]

Visualforce page display errors at the field level

A message for a specific component, such as a warning or error. If an or component is not included in a page, most warning and error messages are only shown in the debug log. Link: apex:message <!– For this example to render properly, you must associate the Visualforce page with a valid account record in […]

Dynamic Apex to check CRUD

How to check using Apex if the current running user is allowed to perform the CRUD operation based on the security settings (FLS, CRUD) You can check this using Schema.DescribeSObjectResult Permissions on an object isCreateable() isAccessible() isUpdateable() isDeletable() public void SObject_Information() { Schema.DescribeSObjectResult drSObj = Schema.sObjectType.Account; System.debug(drSObj.getChildRelationships()); System.debug(drSObj.getRecordTypeInfos()); System.debug(drSObj.getRecordTypeInfosByID()); System.debug(drSObj.getRecordTypeInfosByName()); System.debug(drSObj.isCreateable()); System.debug(drSObj.isAccessible()); System.debug(drSObj.isUpdateable()); System.debug(drSObj.isDeletable()); System.debug(drSObj.isFeedEnabled()); […]

Ensure that the label text changes when the field label changes?

FieldSetMember Class Contains methods for accessing the metadata for field set member fields. Usage Use the methods in the Schema.FieldSetMember class to get details about fields contained within a field set, such as the field label, type, a dynamic SOQL-ready field path, and so on. The following example shows how to get a collection of […]

Previous Posts Next posts