Saturday, 16 November 2013

Insufficient Privileges

Insufficient Privileges
You do not have the level of access necessary to perform the operation you requested. Please contact the owner of the record or your administrator if access is necessary.

Ever got the error above!!

Even if you are an administrator!!

Check that all your components (Apex Classes, Visualforce pages, Visualforce components,...) are using the same API version.

Cheers!!

Wednesday, 13 November 2013

Some example usage of apex:param

 Here are some example usage of the apex:param tag in visualforce page :



<apex:outputText value="{0,date,dd/MM/yyyy}">
        <apex:param value="{!E.Date_du_collecte__c}"/>
    </apex:outputText>
    //convert a decimal to integer in VF
    <apex:outputText value="{0,number,integer}">
        <apex:param value="{!d.key.Degustateur__r.PonderationNiveauTechnique__pc}"/>
    </apex:outputText>
    //replace . by ,
    <apex:outputText value="{0}">
        <apex:param value="{!SUBSTITUTE(TEXT(r.header.InvoiceAmount__c), '.', ',' )}"/>
    </apex:outputText>

    <apex:commandButton value="Process Nickname" action="{!processButtonClick}">
       <apex:param name="nickName" value="{!contact.firstname}" assignTo="{!nickName}"/>
    </apex:commandButton>
   
    <apex:commandButton action="{!DisplayAcompteJournal}" rendered="{!show.showSaveLines}" rerender="head02" value="Afficher Acompte">
        <apex:param name="pos" value="{!numCompteGeneralLine}" assignTo="{!linePosition}" />
    </apex:commandButton>

Dynamic Apex: Get Field Type

Dynamic Apex allows users to access the metadata information about sObject and fields.
The requirement was to get the field type of a sObject.

Schema.DescribeFieldResult f = Schema.sObjectType.Account.fields.Name;

system.debug('## Field Type: '+f.getSObjectField().getDescribe().getType());
//Returns: ## Field Type: STRING

Example of other available methods that can be accessed from f.getSObjectField().getDescribe()
  • getByteLength=765;
  • getCalculatedFormula=null;
  • getController=null;
  • getDefaultValue=null;
  • getDefaultValueFormula=null;
  • getDigits=0;
  • getInlineHelpText=null;
  • getLabel=Account Name;
  • getLength=255;
  • getLocalName=Name;
  • getName=Name;
  • getPrecision=0;
  • getRelationshipName=null;
  • getRelationshipOrder=null;
  • getScale=0;
  • getSoapType=STRING;
  • getSobjectField=Name;
  • getType=STRING;
  • isAccessible=true;
  • isAutoNumber=false;
  • isCalculated=false;
  • isCascadeDelete=false;
  • isCaseSensitive=false;
  • isCreateable=true;
  • isCustom=false;
  • isDefaultedOnCreate=false;
  • isDependentPicklist=false;
  • isDeprecatedAndHidden=false;
  • isDisplayLocationInDecimal=false;
  • isExternalId=false;
  • isFilterable=true;
  • isGroupable=true;
  • isHtmlFormatted=false;
  • isIdLookup=false;
  • isNameField=true;
  • isNamePointing=false;
  • isNillable=true;
  • isPermissionable=false;
  • isRestrictedDelete=false;
  • isSortable=true;
  • isUnique=false;
  • isUpdateable=true;
  • isWriteRequiresMasterRead=false;

Refer to salesforce documentation for further information