Skip to main content

Posts

Showing posts from March, 2014

Check Package Installation based on Name Space Prefix..

How can you ensure particular package is installed or not in your org.  Here is some code snippet which will help you on the same.  let say the package prefix is invoiceit_crmx. String sExtensionNameSpace = 'invoiceit_crmx';     Boolean isInstalled;     try{     if( Userinfo.isCurrentUserLicensed(sExtensionNameSpace )){     isInstalled = true;     }     else{     isInstalled = false;     }     }catch(Exception ex){     isInstalled  = false;         ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.Info,'Please  install CRM extension package to access these records');     ApexPages.addMessage(myMsg);              } If package is not installed then It will through Type exception. You can handle that exception and show...

Retrieving Value From SelctionOption List

Hi Guys  I am going to share about one issue which I have come across.  I was just  comparing some value of selectOption list by iterating that list. Here is the code:- list<SelectOption> listOfOptions; listOfOptions = new list<SelectOption>(); listOfOptions.add(new SelectOption('a','a') ); listOfOptions.add(new SelectOption('1','1') ); listOfOptions.add(new SelectOption('A','A') ); listOfOptions.add(new SelectOption('@','@') ); for(SelectOption option:listOfOptions){    if(option== 'A'){         System.debug('hi');    } } COMPILE ERROR: Comparison arguments must be compatible types: System.SelectOption, String To avoid this error we need to use getValue() met hod. list<SelectOption> listOfOptions; listOfOptions = new list<SelectOption>(); listOfOptions.add(new SelectOption('a','a') ); listOfOptions.add(new SelectOption('1','1') ...

Restricting User to Double Click on Button

Hey Guys !!! This post is regarding to avoid one small issue I have come across it. Let say there is a visual force page where input fields and one button is present. When that button is clicked records are inserted in to the object. If button is clicked twice in same time(double click) then records(duplicate records ) are being created twice.  How will we avoid that? How will restrict user to do double click on button? Here I am sharing some snippet of code.Hope It will help you. V isualforce Page <apex:page standardController="Account">     <apex:form >         <apex:pageMessages id="messages"></apex:pageMessages>         <apex:pageBlock title="Avoid Doublle Click" >             <apex:pageBlockButtons location="both">                                  <apex:act...