Posts

Showing posts from August, 2017

How to call a Visual Flow using Button and VF Page

Image
Through Button:   Call by using the URL Through VF page: Flow with a input Parameter <apex:page standardController="Case" tabStyle="Case" >     <flow:interview name="ModemTroubleShooting">         <apex:param name="vaCaseNumber" value="{!Case.CaseNumber}"/>     </flow:interview> </apex:page> P.S:  Comment Below for any Clarification or help!! Happy working!! :) :) 

Some Common Errors in the Visual flow

Error: An unhandled fault has occurred in this flow An unhandled fault has occurred while processing the flow. Please contact your system administrator for more information Solution:  You Would get a detailed error description to the register email. Error: An Apex error occurred: System.DmlException: Insert failed. First exception on row 0; first error: INVALID_CROSS_REFERENCE_KEY, Task Record Type ID: this ID value isn't valid for the user: : [RecordTypeId]  Solution: The user Might not have access to the Particular Record Type. Or you may be refreing to 15 Digit RecordType Id. Refer 18 Digit ID to solve the issue. Error: Error Occurred: The number of results does not match the number of interviews that were executed in a single bulk execution request. Solution: The size of the return value needs to match the input value. Resolved the issue by using void. P.S:  Comment Below for any Clarification or help!! Happy working!! :) :)  ...

Call a Apex class from a Flow [ @InvocableMethod ]

Image
Two options to call a Apex class from flow  @InvocableMethod  Process.Plugin interface. I prefer Using  @InvocableMethod which is much shorter and more straight forward to follow. It is also more efficient when dealing with multiple records. Code: global class lookUpAccountAnnotation {    @InvocableMethod    public static List<String> getCampaignIds( List<Campaign> campaignList ) {       List<Id> campaignIds = new List<Id>();       List<Campaign> campaign= [SELECT Id FROM Campaign WHERE Name in :campaignList];       for (Campaign c : campaign) {          campaignIds .add(c.Id);       }       return campaignIds;    } } Flow: When you include  @InvocableMethod it would sit in apex Dropdown of ...

Get the custom setting values in the apex code

Let Example__c  be your Custom settings name and  Active__c be one of your Field. Code: To get All the values List<Example__c > mcs = Example__c .getall().values(); system.debug(mcs); To get Particular Field Value list<Example__c > a = [Select Active__c From Example__c ]; To get the single record Value with Name 'Test1' . Example__c test= Example__c .getValues('Test1'); system.debug(test); P.S:  Comment Below for any Clarification or help!! Happy working!! :) :) 

Call Batch Apex class from Trigger

Trigger: trigger AccountTrigger on Account (after update) {     List<Account> ack= new List<Account>();     for (Integer i=0;i<Trigger.new.size();i++) {         if (Trigger.new[i].Name!=Trigger.old[i].Name) {             ack.add(Trigger.new[i]);         }     }            Database.executeBatch(new AccountBatchClass(ack)); } Batch Class with Iterable Start Method: global class AccountBatchClass implements Database.Batchable<Account>{           List<Account> act= new  List<Account>();          //Constructor to i...

Error: Compile Error: Illegal conversion from String to System.PageReference

Controller: public PageReference getURL(){ String    url='www.google.com'; //your Logic return url; }  When you save it would throw and error Error: Compile Error: Illegal conversion from String to System.PageReference you were supposed to return a PageRefernce( A PageReference is a reference to an instantiation of a page ) not Just simple String Solution: Create an instantiation of a page and return the instance. public PageReference getURL(){ String    url='www.google.com'; //your Logic PageReference pageRef = new PageReference(url); return pageRef; } P.S:  Comment Below for any Clarification or help!! Happy working!! :) :) 

Snackbar/Toast In VF Page

Image
Snackbar/Toast In VF Page Code:  <apex:page id="page" docType="html-5.0" standardStylesheets="true" showHeader="false" sidebar="false" applyHtmlTag="true" Controller="HHNGroupOrdercontrollerAlert"> <html xmlns="http://www.w3.org/1999/xhtml">             <head>          <style type="text/css">                         #snackbar {             visibility: hidden;             min-width: 250px;             margin-left: -125px;             background-color: #333;             color: #fff;             tex...

Disable VF Command Button After First Click

Image
Disable VF Command Button After First Click Code: If you are using command button <apex:commandButton action="{!saveRec}" value="Save"  /> Replace It with the below Code: <apex:actionStatus id="disablebtn">           <apex:facet name="stop">                       <apex:commandButton action="{!saveRec}" status="disablebtn"                     value="Save" disabled="false" rerender="mySaveStatus"/>                </apex:facet>                <apex:facet name="start">                   <apex:commandButton action="{!saveRec}" status="disablebtn"                          value="Processing..."...

Embed Special Characters in VF Page

Image
Embed & " < > and lot more symbols in VF Page using the below character sequence Code: <body>          <h1> Testing &amp; Blogging </h1>         </body> Result: &quot; " Double quote &amp; & Ampersand ("and" sign) &lt; < Less-than &gt; > Greater-than &nbsp; un-linebreak-able space &brvbar; ¦ Vertical line, maybe with gap in middle &copy; © Copyright sign (C in a circle) &frac14; ¼ One quarter &frac12; ½ One half &frac34; ¾ Three quarters &times; × Times sign: narrow x without serifs &divide; ÷ Division sign: a colon : with a dash through it P.S:  Comment Below for any Clarification or help!! Happy working!! :) :) 

Radio Button in VF Page

Image
<apex:selectRadio> command usage in salesforce Code:   VF Page:  <apex:selectRadio value="{!gChoice}">            <apex:selectOption itemLabel=" Choice1" itemValue="Choice1" />              <apex:selectOption itemLabel="Choice2" itemValue=" Choice2"/>             </apex:selectRadio> Controller:   public String gChoice { get; set; } public Order orderTest{Get;set;} orderTest.Group_Type__c= gChoice ; Result: There is an Attribute called "layout" in <apex:selectRadio> button which would allow you radio buttons vertically.     Code:  <apex:selectRadio value="{! gChoice  }"   layout="pageDirection">            <apex:selectOption itemLabel=" Choice1" itemValue="Choice1...