• MY VF and Apex
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 6
    Questions
  • 9
    Replies

hi friends,

i am using visualforce page and apex class to create standard user and to view user record as well as for edit functionality...

 

i haven't used <apex:detail/> to view record of any particular user...because by using this i am going to standard look and feel...

insted of using detail i have used simple vf  and in that used outputfield to dislay users record

 

here is my code..

 

 

i want to use a command button for reset password ,i haven't written any code in method(reset) of extension ...

how method will be written in extension (say method in extesnion  is reset)

<apex:page standardController="User" tabStyle="MyAdmin__tab" extensions="StaffandUserDetailPageExtension" >  <!--  <apex:detail title="false" relatedList="false"/> -->
    <apex:form >
        <apex:pageBlock mode="edit">
        <apex:pageMessages />
            <apex:pageBlockButtons >
                   
                    <apex:commandButton action="/apex/EditStaffAndUser?id={!id}" value="Edit"/>
                    <apex:commandButton action="/apex/AdminListView?intFocus=5" value="List View"></apex:commandButton>
                <!--    <apex:commandButton action="{!resetpassword}" value="Reset Password"/> -->
                    
                 </apex:pageBlockButtons>
              
              <apex:pageBlockSection title="User Information" columns="2" collapsible="false"> 
             
           
                 <apex:outputField value="{!User.User_Types__c}"/> 
                  <apex:pageBlockSectionItem >
                         <apex:outputLabel value="Active"/>
                         <apex:outputfield value="{!User.IsActive}"/>
                  </apex:pageBlockSectionItem> 
                
                  <apex:outputField value="{!User.ProfileId}"/>
                  <apex:outputField value="{!User.FirstName}"/>
                  <apex:outputField value="{!User.Username}"/>
                  <apex:outputField value="{!User.LastName}"/>
                  <apex:outputField value="{!User.Email}"/>
                  <apex:outputField value="{!User.alias}"/>
                  <apex:outputField value="{!User.CommunityNickName}"/>
     
                  
                 
                  </apex:pageBlockSection>
        
            
           
            

          
                    
                    
            <apex:pageBlockSection >

                  
                   
                   <apex:outputField value="{!User.Phone}"/>
                   <apex:outputField value="{!User.Extension}"/>
                   <apex:outputField value="{!User.Fax}"/>
           
                   <apex:outputField value="{!User.Title}"/>
                   <apex:outputField value="{!User.CompanyName}"/>
          
                   <apex:outputField value="{!User.Department}"/>
                   

         
                   
          
                   </apex:pageBlocksection>
              
              
            
      
      
          
            <!-- 
               <apex:pageBlockSection title="Other Information" columns="1" collapsible="false">
                   <apex:outputField value="{!User.EmailEncodingKey}"/>
                   <apex:outputField value="{!User.TimeZoneSidKey}"/> 
                   <apex:outputField value="{!User.LocaleSidKey}"/>
                   <apex:outputField value="{!User.LanguageLocaleKey}"/>
               </apex:pageBlockSection>
             --> 
               
        
            
              </apex:pageBlock>
              </apex:form>
   
  
 
 
 


   
</apex:page>

 Thanks in advance

suppose i have created two object as Job  and Job Task..

their is a master  detail relationship between job(master) and job task (detail)...

 

and i want that their should not be a repeated value for a job task (for a particular job)..

if i am creating a record for job as Painting and size is the job task...(then there should not be any more reord(Duplicate) named as size for painting job)...

and if i am creating any other record of job named as Finishing,here i should allow to create size for this job too...

how can i control...

i have taken job task name as Text (Record Name)...

i have written a trigger but there i am not able to create any duplicate value for Job Task.

 

here is my code... is there any need to make modification in my trigger...?



trigger duplicateJobTasks on Job_Task__c (before insert,before update) {
List<Job_Task__c> lstGC = new List<Job_Task__c>();
if(Trigger.isInsert)
{
    for(Job_Task__c g:Trigger.New)
    {
        lstGC=[select id from Job_Task__c where Name =: g.Name];
        if(lstGC.size()==1)
        {
           for(Job_Task__c g1:lstGC)
               g.Name.addError('Job Task with same Name Exists');
              
               
        }
        
    }
}
else if(Trigger.IsUPdate)
{
for (Job_Task__c no : Trigger.new)
           {
              Job_Task__c old = Trigger.oldMap.get(no.id);
              if (no.Name != old.Name)
              {
                 lstGC = [select id from Job_Task__c where Name =: no.Name];
         
                 if (lstGC.size() > 0) 
                 {
                    for(Job_Task__c noOld : lstGC) 
                    {
                           no.Name.addError('Job Task with same Name Exists');
                    }
                 }
                  
              }
           }
           }
           
           if(lstGC.size() > 0)
       update lstGC;    
}

 

hi friends....

could any one please tell me that how to create user with the help of visualforce page?

 

i have tried it but getting following problems--

not able to hide certain fields(like profile,user role,locale fields etc.) can i hide these fields... i mean i want that thease fields value should be set by default with the help of Apex class..

 

can i do this??

please provide me source code..

 

 

Thanks :)

hi friends,

i have created two object named as vendor and vendor contact(master-detail relationship)...

i have used visualforce page (to create,to edit,detail page etc) for both vendor as well as vendor contact too...

whenever i delete any vendorcontact record from its detail page,after deletion it goes to list view of vendor contact... here i want that it should get back to respected master record.... for this i have created class to override delete button but getting error like this..

 


System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Vendor_Contact__c.Vendor__c
Class.DeleteVendorContactExtension.CheckDelete: line 19, column 14 External entry point 

 

 

here is my code

 

vf page

 

<apex:page standardController="Vendor_Contact__c" extensions="DeleteVendorContactExtension" action="{!CheckDelete}">
 
</apex:page>

 

extension

 

 

public class DeleteVendorContactExtension
{
    private Id JobId;
    private final Vendor_Contact__c objVC;
    public DeleteVendorContactExtension(ApexPages.StandardController controller)
    {
      this.objVC=(Vendor_Contact__c)controller.getrecord();   
    }
   
     public PageReference CheckDelete()
     {
   
     JobId = objVC.Vendor__c;
    
        try
        {
     //   String strid;
      //  strid = objVC.Vendor__c; 
     
       Database.delete(objVC);   
        }
        catch(System.DMLException e)
        {
        return null;
        }
        PageReference p =  new Pagereference('/apex/VendorListView?id'+JobId);
       p.setRedirect(true);
      
       return p;  
     }

}



 

Thanks in advance

 

i have created a userrole with the help of vf page.... i have created a vf page on which it will display all the list of Roles... i have also created a vf page as detail page of role...

but when I am clicking on particular role it shows error like this..

 

to create new user role

 

<apex:page standardController="UserRole">
   <apex:sectionHeader title="Role Creation"></apex:sectionHeader>
    <apex:form >
        <apex:pageBlock mode="edit">
        <apex:pageMessages />
            <apex:pageBlockButtons >
                    <apex:commandButton action="{!save}" value=" Save "></apex:commandButton>
                    <apex:commandButton action="{!cancel}" value="Cancel"></apex:commandButton>
                 </apex:pageBlockButtons>
             
              <apex:pageBlockSection title="Role Information" columns="2" collapsible="false"> 
                  <apex:inputField value="{!UserRole.Name}"/>
                  <apex:inputField value="{!UserRole.ContactAccessForAccountOwner}"/>
                  <apex:inputField value="{!UserRole.CaseAccessForAccountOwner}"/>
                  <apex:inputField value="{!UserRole.ForecastUserId}"/>
                 
                 
                 
                
                  <apex:inputField value="{!UserRole.PortalRole}"/>
                  <apex:inputField value="{!UserRole.PortalType}"/>
                  <apex:inputField value="{!UserRole.RollupDescription}"/>
                 
                 
                 
             
              </apex:pageBlockSection>
             
              </apex:pageBlock>
              </apex:form>
</apex:page>

 

detail of Userrole

 

<apex:page standardController="UserRole" tabStyle="Admin__c">
    <apex:detail title="true" relatedList="true"/>
</apex:page>

 

Error is-:

 

An internal server error has occurred An error has occurred while processing your request. The salesforce.com support team has been notified of the problem. If you believe you have additional information that may be of help in reproducing or correcting the error, please contact Salesforce Support. Please indicate the URL of the page you were requesting, any error id shown on this page as well as any other related information. We apologize for the inconvenience.

Thank you again for your patience and assistance. And thanks for using salesforce.com!

Error ID: 498655240-27989 (-845424718) 

hi all,

can we create User role with the help of vf page and apex??

can we??

if yes then how??

 

hi friends,

i am using visualforce page and apex class to create standard user and to view user record as well as for edit functionality...

 

i haven't used <apex:detail/> to view record of any particular user...because by using this i am going to standard look and feel...

insted of using detail i have used simple vf  and in that used outputfield to dislay users record

 

here is my code..

 

 

i want to use a command button for reset password ,i haven't written any code in method(reset) of extension ...

how method will be written in extension (say method in extesnion  is reset)

<apex:page standardController="User" tabStyle="MyAdmin__tab" extensions="StaffandUserDetailPageExtension" >  <!--  <apex:detail title="false" relatedList="false"/> -->
    <apex:form >
        <apex:pageBlock mode="edit">
        <apex:pageMessages />
            <apex:pageBlockButtons >
                   
                    <apex:commandButton action="/apex/EditStaffAndUser?id={!id}" value="Edit"/>
                    <apex:commandButton action="/apex/AdminListView?intFocus=5" value="List View"></apex:commandButton>
                <!--    <apex:commandButton action="{!resetpassword}" value="Reset Password"/> -->
                    
                 </apex:pageBlockButtons>
              
              <apex:pageBlockSection title="User Information" columns="2" collapsible="false"> 
             
           
                 <apex:outputField value="{!User.User_Types__c}"/> 
                  <apex:pageBlockSectionItem >
                         <apex:outputLabel value="Active"/>
                         <apex:outputfield value="{!User.IsActive}"/>
                  </apex:pageBlockSectionItem> 
                
                  <apex:outputField value="{!User.ProfileId}"/>
                  <apex:outputField value="{!User.FirstName}"/>
                  <apex:outputField value="{!User.Username}"/>
                  <apex:outputField value="{!User.LastName}"/>
                  <apex:outputField value="{!User.Email}"/>
                  <apex:outputField value="{!User.alias}"/>
                  <apex:outputField value="{!User.CommunityNickName}"/>
     
                  
                 
                  </apex:pageBlockSection>
        
            
           
            

          
                    
                    
            <apex:pageBlockSection >

                  
                   
                   <apex:outputField value="{!User.Phone}"/>
                   <apex:outputField value="{!User.Extension}"/>
                   <apex:outputField value="{!User.Fax}"/>
           
                   <apex:outputField value="{!User.Title}"/>
                   <apex:outputField value="{!User.CompanyName}"/>
          
                   <apex:outputField value="{!User.Department}"/>
                   

         
                   
          
                   </apex:pageBlocksection>
              
              
            
      
      
          
            <!-- 
               <apex:pageBlockSection title="Other Information" columns="1" collapsible="false">
                   <apex:outputField value="{!User.EmailEncodingKey}"/>
                   <apex:outputField value="{!User.TimeZoneSidKey}"/> 
                   <apex:outputField value="{!User.LocaleSidKey}"/>
                   <apex:outputField value="{!User.LanguageLocaleKey}"/>
               </apex:pageBlockSection>
             --> 
               
        
            
              </apex:pageBlock>
              </apex:form>
   
  
 
 
 


   
</apex:page>

 Thanks in advance

suppose i have created two object as Job  and Job Task..

their is a master  detail relationship between job(master) and job task (detail)...

 

and i want that their should not be a repeated value for a job task (for a particular job)..

if i am creating a record for job as Painting and size is the job task...(then there should not be any more reord(Duplicate) named as size for painting job)...

and if i am creating any other record of job named as Finishing,here i should allow to create size for this job too...

how can i control...

i have taken job task name as Text (Record Name)...

i have written a trigger but there i am not able to create any duplicate value for Job Task.

 

here is my code... is there any need to make modification in my trigger...?



trigger duplicateJobTasks on Job_Task__c (before insert,before update) {
List<Job_Task__c> lstGC = new List<Job_Task__c>();
if(Trigger.isInsert)
{
    for(Job_Task__c g:Trigger.New)
    {
        lstGC=[select id from Job_Task__c where Name =: g.Name];
        if(lstGC.size()==1)
        {
           for(Job_Task__c g1:lstGC)
               g.Name.addError('Job Task with same Name Exists');
              
               
        }
        
    }
}
else if(Trigger.IsUPdate)
{
for (Job_Task__c no : Trigger.new)
           {
              Job_Task__c old = Trigger.oldMap.get(no.id);
              if (no.Name != old.Name)
              {
                 lstGC = [select id from Job_Task__c where Name =: no.Name];
         
                 if (lstGC.size() > 0) 
                 {
                    for(Job_Task__c noOld : lstGC) 
                    {
                           no.Name.addError('Job Task with same Name Exists');
                    }
                 }
                  
              }
           }
           }
           
           if(lstGC.size() > 0)
       update lstGC;    
}

 

hi friends,

i have created two object named as vendor and vendor contact(master-detail relationship)...

i have used visualforce page (to create,to edit,detail page etc) for both vendor as well as vendor contact too...

whenever i delete any vendorcontact record from its detail page,after deletion it goes to list view of vendor contact... here i want that it should get back to respected master record.... for this i have created class to override delete button but getting error like this..

 


System.SObjectException: SObject row was retrieved via SOQL without querying the requested field: Vendor_Contact__c.Vendor__c
Class.DeleteVendorContactExtension.CheckDelete: line 19, column 14 External entry point 

 

 

here is my code

 

vf page

 

<apex:page standardController="Vendor_Contact__c" extensions="DeleteVendorContactExtension" action="{!CheckDelete}">
 
</apex:page>

 

extension

 

 

public class DeleteVendorContactExtension
{
    private Id JobId;
    private final Vendor_Contact__c objVC;
    public DeleteVendorContactExtension(ApexPages.StandardController controller)
    {
      this.objVC=(Vendor_Contact__c)controller.getrecord();   
    }
   
     public PageReference CheckDelete()
     {
   
     JobId = objVC.Vendor__c;
    
        try
        {
     //   String strid;
      //  strid = objVC.Vendor__c; 
     
       Database.delete(objVC);   
        }
        catch(System.DMLException e)
        {
        return null;
        }
        PageReference p =  new Pagereference('/apex/VendorListView?id'+JobId);
       p.setRedirect(true);
      
       return p;  
     }

}



 

Thanks in advance

 

hi all,

can we create User role with the help of vf page and apex??

can we??

if yes then how??