Google adds

All Senerios


Scenario : 1   DML Call Using Constructor
-----------------------------------------------------------------------------------------------------------------------
public class InsertObjectController
{
 public Boolean myFlag {get; set;}
 public Account acc    {get; set;}

 public InsertObjectController()
 {
  myFlag=false;
 }

 public void init()
 {
  if (!myFlag)
  {
   acc=new Account();
   acc.Name='Mindfire Account';
   insert acc;
   myFlag=true;
  }
 }
}
-----------------------------------------------------------------------------------------------------------------
<apex:page controller="InsertObjectController">
  <apex:form >
    <apex:actionFunction name="doInit" action="{!init}" rerender="allPanel"/>
    <apex:outputPanel id="allPanel">
      <apex:outputPanel rendered="{!NOT(myFlag)}">
        <p align="center" style='{font-family:"Arial", Helvetica, sans-serif; font-size:20px;}'>
         <apex:image value="/img/loading.gif"/>&nbsp;Please wait</p>
        <script>
           window.onload=function()
           {
             doInit();
           };
        </script>
      </apex:outputPanel>
      <apex:outputPanel rendered="{!myFlag}">
        <apex:pageBlock title="Account Details">
          <apex:pageBlockSection >
            <apex:inputField value="{!acc.id}"/>
            <apex:inputField value="{!acc.name}"/>
            <apex:inputField value="{!acc.type}"/>
            <apex:inputField value="{!acc.industry}"/>
          </apex:pageBlockSection>
        </apex:pageBlock>
      </apex:outputPanel>
    </apex:outputPanel>
  </apex:form>
</apex:page>


How can i identify the admin (standard/cloned) profile of current User using Apex Code

String ProfId= UserInfo.getProfileId();
List<Profile> lstP = [select id,name,UserLicenseId,UserType from Profile where id =: ProfId and name like '%admin%' ];
system.debug('----> Profile Data is --->'+lstP[0]);

No comments:

Post a Comment

All Governor Limit

Number of SOQL queries: 100 Number of query rows: 50,000 Number of SOSL queries: 20 Number of DML statements: 150 Number of DML rows: 10,...