• Amit Singh.ax1042
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 38
    Questions
  • 38
    Replies

Estimate,Vendor,Purchase Order are objects

In Estimate there is look up for vendor and In Purchase Order There is also lookup for Vendor Object (But for lookup in Purchase order i want some Filter criteria - Remember that there is no direct relationship between Estimate and Purchase Order),

example,
Est1 is an estimate for vendor v1,
Est2 is an estimate for vendor v2.

then while creating PO,for vendor i should get only two value v1 and v2 (if i get it as picklist then will be more better),there might be no. of vendors in org. but i should get only two value v1 and v2.

How can I solve this issue.?

Thanks,

Hi Friends,
I have created an object Purchase Order...
in Purchase Order Following are the Fields...
Name
Invoice Created (Picklist-: Yes,No,Partally)
Status (Picklist-: Sent,Open)
Amount (Currency)


Another Object Is-:
Invoice
Fields of Invoice are

Purchase Order (look up- PO is master)
Date (Date)
Amount (Currency)


i have override the Purchase order tab using visualforce page...
(i am using Page Block table in my Vf Page)

I Donot want to create Invoice From Invoice Tab...
i want to use command button in my Purchase Order Page Block Table...
so I will be able to create Invoice for Each PO...

Suppose i am creating any Invoice By click Create Button Next to any PO record...
i should get navigate to create Invoice Page (Where Purchase Order will be automatically filled)
( i am able to do this)

but I want that, Suppose Purchase Order Record (For which I want to Create Invoice),if its status field is Open then if I click on create Invoice button next to Purchase Oreder then I should Not allow to land to CreateNewInvoice Visualforce page... I should get message like "You can not create Invoice For this Purchase Order because its Status is Open"...

and if for any Purchase Oreder its status is Sent then after clicking create Invoice Button next to PO record I should land to Create New Invoice Visualforce...


How It can be Possible???

<apex:page controller="DisplayPOunderjobtabextension">

  <apex:form >
   <apex:pageBlock >
     
     
    
    
     <apex:commandButton action="{!CreatePO}" value="New Purchase Order" id="btn1"/> 
    
    <br/>
    <apex:pageBlockTable value="{!purchaseorder}" var="po">
    
    <apex:column headerValue="Action">

         
          <apex:commandButton value="Create Invoice" action="/apex/CreateInvoiceFromPO?id={!po.id}"/>
         </apex:column> 
    
    
      <apex:column headerValue="Name">
       <apex:outputLink tabindex="tab1" value="/apex/PODetailpage?id={!po.Id}">{!po.Name}</apex:outputLink>
      </apex:column>
      
      <apex:column headerValue="Invoice Created">
      <apex:outputField value="{!po.Invoice_Created__c}"/> 
      </apex:column>
            
       <apex:column headerValue="Status">
       <apex:outputField value="{!po.Status__c}"/>
      </apex:column>
      
      <apex:column headerValue="Total Amount">
       <apex:outputField value="{!po.Amount__c}"/>
      </apex:column>
      
    
    </apex:pageBlockTable>
    

   
  
    <apex:pageBlockSection rendered="{!purchaseorder.Size == 0}">
     <apex:pageBlockSectionItem >
      No records to display.
     
     </apex:pageBlockSectionItem>
    </apex:pageBlockSection>
    
   </apex:pageBlock>
   
  </apex:form>
</apex:page>




Apex Class


public class DisplayPOunderjobtabextension
{
public List<Purchase_Order__c> purchaseorder{get;set;} 
//public List<Purchase_Order__c> purchaseorder1{get;set;} 
public DisplayPOunderjobtabextension()
{
String theID = ApexPages.CurrentPage().getParameters().get('id');
purchaseorder = [Select id,Name,Due_Date__c,Issue_Date__c,job__c,Status__c,Total_Amount__c,Vendor__c,Approved_By_Staff__c,Invoice_Created__c from Purchase_Order__c where Job__c =: theID Order BY Name];
}

 public PageReference CreatePO()
    {
       String jobid;
       String theId=ApexPages.CurrentPage().getParameters().get('id');
       Job__c job = [Select Id from Job__c where id =: theID];
       jobid=job.Id;
       
      PageReference p = Page.CreateNewPurchaseOrder;
       p.setredirect(true);
     p.getParameters().put('jobid',theID); 
     return p;
       return null;
    }


}

 

I have Following Objects
1)Job

2)Vendor

3)Estimate Line Item (ELI)
Fields- Job (Master),Vendor(Look up),Amount

4)Purchase Order
Fields- Job (Master),Vendor (Look up),PO# (Auto number) etc.

5)Purchase Order Line Item
Fields- Purchase order (Master),Estimate Line Item (Look up)

(Here Master denotes MD relationship,Lookup- Lookup relationship)


i have taken a button named as Create PO(to create Purchase order)on Estimate Line Item detail Page

and override it with vf pafe, its Job will be pulled from ELI and vendor also will be pulled from ELI,and other fields value of Purchase order will be given manually.... after save a child Record (POLI) of PO also will be created with Estimate Line Item,and Amount field...

you will get it from code,

Now suppose i am going to create a PO from any Other Estimate Line Items Detail Page... and this time we have to check whether PO for this vendor (Estimate Line Items Vendor) is already there in any PO or not??
then we have to open a popup..asking .... PO for Estimate Line Items Vendor is already created... do you want to add this item into existing Vendors POLI or want to create New PO?...
if yes then add ELI into POLi of that vendors PO.
and if no again Open a page to create New PO.


Create PO--(Button is override with vf page)...

<apex:page standardController="Estimate_Line_Items__c" tabStyle="Job__c" extensions="CreatePOFromEstimateLIExtension">


 <head>

</head> 
 <apex:form >
  <apex:sectionHeader title="Purchase Order Details"/>
     <apex:pageBlock >
         <apex:pagemessages />
             <apex:pageBlockButtons >
                 <apex:commandButton action="{!saveme}" value="Save"></apex:commandButton>
                 <apex:commandButton action="{!cancel}" value="Cancel" immediate="true"></apex:commandButton>
             </apex:pageBlockButtons>
             
             <apex:pageBlockSection title="Information" columns="2" collapsible="true">            
             
                  
                  <apex:pageBlockSectionItem >
                  <apex:outputLabel value="Job"/>
                  <apex:outputField value="{!PO.Job__c}"/>
             </apex:pageBlockSectionItem>
             
             
              <apex:pageBlockSectionItem >
                  <apex:outputLabel value="Vendor"/>
                  <apex:outputField value="{!PO.Vendor__c}"/>
             </apex:pageBlockSectionItem>
             
             <apex:pageBlockSectionItem >
                  <apex:outputLabel value="Status"/>
                  <apex:inputField value="{!PO.Status__c}" required="true"/>
             </apex:pageBlockSectionItem>  
             
             
           
            
           <apex:inputField value="{!PO.Issue_Date__c}"/>
            <apex:inputField value="{!PO.Due_Date__c}"/>
            
            <apex:pageBlockSectionItem >
                  <apex:outputLabel value="Approved By"/>
                  <apex:inputField value="{!PO.Approved_By_Staff__c}"/>
             </apex:pageBlockSectionItem>  
            
        
             

         
             
  </apex:pageBlockSection>
            
</apex:pageBlock>
</apex:form> 
 

 
</apex:page>




Apex Class-:


public class CreatePOFromEstimateLIExtension 
{
    private final Estimate_Line_Items__c ELI;
    public String ELIid{get;set;}
   Public Purchase_Order__c PO;
   public String strId{get;set;}
   public PO_Line_Item__c POLI;
   String jobid,jobId1;
   public List<PO_Line_Item__c> lstPOLI=new List<PO_Line_Item__c>();
   

  
    public CreatePOFromEstimateLIExtension(ApexPages.StandardController controller) 
    {
     this.ELI = (Estimate_Line_Items__c)controller.getRecord();
     String ELIid=ApexPages.CurrentPage().getParameters().get('id');
     
     
     Estimate_Line_Items__c obj1 = [Select id,Job__c from Estimate_Line_Items__c where id =: ELIid Limit 1];
     jobId1=obj1.Job__c;
    //PO.Job__c = ELI.Job__c ;
    
    }
   Public Purchase_Order__c getPO()
    {
        PO = new Purchase_Order__c();
        String ELIid=ApexPages.CurrentPage().getParameters().get('id');
        Estimate_Line_Items__c obj = [Select id,Job__c,Vendor__c from Estimate_Line_Items__c where id =: ELIid Limit 1];
        PO.Job__c = obj.Job__c;
        PO.Vendor__c = obj.Vendor__c;
        return PO;
    }
    
    Public PageReference Saveme()
    {
    String strPOid;
     try
     {
     insert PO;
     jobid = PO.Job__r.Id;
     strPOid = PO.Id;
     }
     catch(System.DMLException e)
     {
     return null;
     }
     
      String ELIid=ApexPages.CurrentPage().getParameters().get('id');
      Estimate_Line_Items__c obj = [Select id,Job__c,Total_Amount__c,Vendor__c from Estimate_Line_Items__c where id =: ELIid];
         POLI = new PO_Line_Item__c();
         POLI.Purchase_Order__c = strPOid;
         POLI.Amount__c = obj.Total_Amount__c;
         POLI.Estimate_Line_Item__c = obj.Id;
         lstPOLI.add(POLI);
         insert lstPOLI;
      
    
     
  
       PageReference pageRef =  new Pagereference('/apex/JobListView?id='+jobId1+'&intFocus=6');
       pageRef.setRedirect(true);
       return pageRef;
     
     
    return null;
    } 
    


}

 Thanks,

Hi Friends,

i Have Created an object Estimate... and created a custom button Approve...and override it with a visualforce...

 

<apex:page standardController="Estimate_Line_Items__c" extensions="ApproveEstimateController" action="{!autoRun}">
  <apex:sectionHeader title="Auto-Running Apex Code"/>
  <apex:outputPanel >
      You tried calling Apex Code from a button.  If you see this page, something went wrong.  You should have
      been redirected back to the record you clicked the button from.
  </apex:outputPanel>
</apex:page>




Apec Class-->

public class ApproveEstimateController 
{
private final Estimate_Line_Items__c est;
    public ApproveEstimateController(ApexPages.StandardController controller)
    {
    this.est=(Estimate_Line_Items__c)controller.getRecord();
    }
 public PageReference autoRun() 
    {
    
         try
        {
        est.Approved__c=true;
        update est;
        }
        catch(System.DMLException e)
        {
        return null;
        }
    
     String theId = ApexPages.currentPage().getParameters().get('id');
     if (theId == null) 
        {
            // Display the Visualforce page's content if no Id is passed over
            return null;
        }
        PageReference pageRef = new PageReference('/' + theId);
        pageRef.setRedirect(true);
        return pageRef;
    
    }        

 
}

 

 

now the thing is that,,,when i am pressing this button from any Estimate Line Items Record page...

i want a popup window to ask "Do you want to Approve this Item"...after pressing yes it should process otherwise nothing shoul happen...

How it can be???

How to customize Notes and Attachment section?
Can we make visualforce pages to customize this functionality?



I Have Created an object as Job,in this object following are the fields,
start date (data type is date)
completion date (data type is date)
no. of dayas (data type is number)
now i want to use a field as due date...
and
due date = start date + number of days excluding sat / sun...
how can i use this???


I have taken one custom button "Approve" on my detail page. When i click on Approve button then i want to copy some field from that record into another object.

The another requirement is that after clicking on Approve button that particular record should not be available for editing.

 

How to do this?

hi friends,

i am getting problem while creating trigger on one of my object...

i have created following objects-

Job

Job Task

Job Task Role

 

and

Schedule Template

Schedule Task

Schedule Task Role

 

1)job Task is child of Job,And Job Task Role is child of Job Task

2)Schedule Task is child of Schedule Template,And Schedule Task Role is child of Schedule Task

and

Job Task is same as Schedule Task (i am talking about fields-fields are same)

Job Task Role is same as Schedule Task Role (" "    "      ").

 

and there is look up relationship between job and schedule template (job is child and schedule template is master..)

 

i want that when i create a job, ishould select a schedule template.... then.. when i save..all schedule task of that particular template should be copy into job task (record)....and all schedule task role should be in job task role...

 

example-

i have created a schedule template as ST and

in ST there is two record for schedule task as  task 1 and task 2

in task 1 there is one record for schedule task role say role 1

in task 2 there is one record for schedule task role say role 2

 

and now i am going to create a job

job1

in this if i am selecting schedule template as ST then all schedule task should copy into job task and all schedule task role should copy into jobtaskrole (for repected job task, i mean role1 should copy into task1 and role 2 should copy into task2)...

 

i have written following trigger for this... and it is working fine ...

all schedule task i am getting into job task... but problem is for job task role (i am able to copy schedule task role into job task role table but not for particular Job task----- in example role 1 and role 2 both schedule task role is copied for task 2 )...

 

how to solve this....

please make some modification into following codes..

 

 

 

 

 

trigger CopyScheduleTaskInJobTask on Job__c (after insert,after update)
{
    Set<Id> stScheduleTemplateId = new Set<Id>();
    Set<Id> stScheduleTaskId = new Set<Id>();
    Set<Id> stJobTaskId = new Set<Id>();
  
    List<Job_Task__c> lstJobTask = new List<Job_Task__c>();
    List<Job_Task_Role__c> lstJobTaskRoleNew=new List<Job_Task_Role__c>();
    List<Schedule_Template__c> lsttemp = new List<Schedule_Template__c>();
    String strJobId,strSTId,strJobTaskId,str;
  
   If(Trigger.isAfter)
   {
       for(Job__c j :Trigger.New)
       {
              stScheduleTemplateId.add(j.Schedule_Template__c);
              strJobId = j.Id;
              strSTId=j.Schedule_Template__c;
       }
     
      system.debug('set..............'+stScheduleTemplateId);
       
      List<Schedule_Task__c> lstScheduleTask = new List<Schedule_Task__c>();
      lstScheduleTask = [Select Name from Schedule_Task__c where Schedule_Template__c IN: stScheduleTemplateId ORDER BY Name];
     
     
       for(Schedule_Task__c s : lstScheduleTask)
       {
            Job_Task__c jt = new Job_Task__c();
            jt.Name = s.Name;
            jt.Job__c = strJobId;
           
            lstJobTask.add(jt);
        }
             insert lstJobTask;
            
              for(Schedule_Task__c st : lstScheduleTask) //For every task has one or more role. These roles are coming from ScheduleTaskRole__c
             {
                 stScheduleTaskId.add(st.Id); // here need to pass ScheduleTaskId, so that all the roles can be retrived whose Schedule Task is stScheduleTaskId
             }
      
      
              Map<Id,Id> mpCustom = new Map<Id,Id>();
             
              for(Job_Task__c jt2: [select Id,Name,Job__r.Schedule_template__c from Job_Task__c where Job__r.Schedule_template__c IN : stScheduleTemplateId ])
               {
                  
                    mpCustom.put(jt2.Job__r.Schedule_template__c,jt2.Id);
                    strJobTaskId = mpCustom.get(jt2.Job__r.Schedule_template__c);
               }
              
               system.debug('set..............'+stScheduleTaskId);
      
               List<Schedule_Task_Role__c> lstScheduleTaskRole=new List<Schedule_Task_Role__c>(); // Created list instance for ScheduleTaskRole__c
               lstScheduleTaskRole=[Select Id,Name,Schedule_Task__c,Schedule_Task__r.Schedule_Template__c,Schedule_Task__r.Name,Schedule_Task__r.Id from Schedule_Task_Role__c where Schedule_Task__c IN : stScheduleTaskId];
      
    
      
               for(Schedule_Task_Role__c st1:lstScheduleTaskRole)
               {   
                    Job_Task_Role__c jt1=new Job_Task_Role__c(); // INstance of Job_Task_Role__c
                    // Now assign role and schedule task from ScheduleTaskRole__c to Job_Task_Role__c
                   //  jt1.Job__c=strJobId; // assign JobId to Job_Task_Role__c.Job__c
                       jt1.Name=st1.Name;
                     jt1.Job_Task__c=mpCustom.get(st1.Schedule_Task__r.Schedule_Template__c);
                  
                   // jt1.Job_Task__c= strJobTaskId;
                    lstJobTaskRoleNew.add(jt1); // add into the list instance
                }
   
                insert lstJobTaskRoleNew;  // Insert list instance      
  
            
      }
}

Hi friends,

i Am facing problem with AutoNumber,

i have created object JobApllication(Master) and Review(Child)...

for review i have taken record name as Job Application number (Data Type is Autonumber)...

 

i have create two application JA1,JA2

 

in JA1,i have created two review ( R-1 and R-2 (Auto number ))

in JA2,i have created two review (now here i am getting R-3,R-4)...i want that for different-different  job application review should start with R-1

 

is it possible?

 

any suggestion how to solve this kind of issue?



Hi friends,

I ma creatin role with the help of vf and apex class...

and displaying roles in Visualforce page with the help of Apex class....

i want to give edit and delete functionalty on vf page... i have given the same...Edit is working properly...

Delete is also working fine... but while i want to delete a role for which any user is assigned it is Showing standard error..(i want to make it custom eg- you can not delete this role)...

 

can i do this???

 

this is my code..

 

public class RoleList

{

        public List<UserRole> list_role{get;set;}   

        public String message {get;set;} 

      public RoleList(ApexPages.StandardController controller)    

        {

         list_role=[Select Name From UserRole Order By Name];       

        }

   public PageReference del()

        {    String delname = ApexPages.CurrentPage().getParameters().get('id'); 

       try       

          {

          Database.delete(delname);  

          }

        catch(System.DMLException e)

        { 

       //         message = 'Whoops! An error occurred -- ';

      //         System.assert(false,message);

          System.assert(false, e.getMessage());        

         } 

  PageReference p=new PageReference('/apex/AdminListView?intFocus=6'); 

  p.setRedirect(true);

    return p;

    }
}

 

Hi friends,

i Am facing problem with AutoNumber,

i have created object JobApllication(Master) and Review(Child)...

for review i have taken record name as Job Application number (Data Type is Autonumber)...

 

i have create two application JA1,JA2

 

in JA1,i have created two review ( R-1 and R-2 (Auto number ))

in JA2,i have created two review (now here i am getting R-3,R-4)...i want that for different-different  job application review should start with R-1

 

is it possible?

 

any suggestion how to solve this kind of issue?

hi friends,

i have created two objects 1)Job 2)Job Task

and there is a master detail relationship between Job and JobTask...

i have created visualforc page to create new Job and Jobtask as well...

i am getting problem while deleting Job Task from its Detail page... Because after deleting it goes to standard list of jobtask...

i want that after deleting any jobtask it should go back to respected Job... i have written apex for this but not able to fetch id of master record...

could any one provide me code to override delete of job task

 

here is my code but not able to retrieve id ob JOB

 

 

public class DeleteJobTask
{
    private final JobTask__c objJT;
    public DeleteJobTask(ApexPages.StandardController controller)
    {
    this.objJT=(Holiday__c)controller.getrecord();
    }
     public PageReference checkDelete()
     {
        try
        {
        Database.delete(objJT);       
        }
        catch(System.DMLException e)
        {
        return null;
        }
        PageReference p =  new Pagereference('/apex/JobDetailPage?id=);
        p.setRedirect(true);
        return p;
     }

}

 

hi friends,

i am getting problem in navigation

 

i have created a visualforce page for my Account object... override it with view button of Account Object... when we view any Account record it will display all the related items in Tab (because here i am using Tab panel)

 

below is my code.

opportunity,contacts(all related items are in the second level tab)... here when we click on any Account record by default it navigate to detail tab... but when i want to create new Contact (i will go to Contact tab)...from there if i will cancel then it goes to detail tab (we should go to contact tab-which was previous one)...

how to solve this issue??

 

 

<apex:page standardController="Account" showHeader="true"
      tabStyle="account">
     
     
     
   <style>
      .activeTab {background-color: #236FBD; color:white;
         background-image:none}
      .inactiveTab { background-color: lightgrey; color:black;
         background-image:none}
   </style>
   <apex:tabPanel switchType="client" tabClass="activeTab" inactiveTabClass="inactiveTab" selectedTab="{!}" id="testTabs">
                 
                 
            
      <apex:tab label="Details" name="AccDetails" id="tabdetails">
         <apex:detail relatedList="false" title="true"/>
      </apex:tab>
      <apex:tab label="Contacts" name="Contacts" id="tabContact">
         <apex:relatedList subject="{!account}" list="contacts" />
      </apex:tab>
      <apex:tab label="Opportunities" name="Opportunities"
                id="tabOpp">
         <apex:relatedList subject="{!account}"
                           list="opportunities"/>
      </apex:tab>
      <apex:tab label="Open Activities" name="OpenActivities"
                id="tabOpenAct">
         <apex:relatedList subject="{!account}"
                           list="OpenActivities" />
      </apex:tab>
      <apex:tab label="Notes and Attachments"
                name="NotesAndAttachments" id="tabNoteAtt">
         <apex:relatedList subject="{!account}"
                           list="NotesAndAttachments" />
      </apex:tab>
   </apex:tabPanel>
 
  
</apex:page>

Hi friends,

i am getting a problem related to Campaign (Standard) Object,

Marketing User License can not be assigned to  more than 2 user( i am using Developer org)...and because of this only these two users can create and edit Campaign...

is there any charge for this feature License??

one who is going to use my App... How he will handle all these things??

 

Hi friends,

I want to remove some texts from the Campaign Detail Page...it comes by default

i am getting this ling in every detail page

"Campaigns statistics calculations may be delayed by up to 10 minutes."

(i am not getting any option to remove this from Campaign Page Layout... what does it mean??)

how to solve this issue?

hi friends,

i am getting problem while validating zip field

i want to use only numbers and text in my zip field...

how to achieve this...

i have used something like this,

NOT(REGEX(Zip__c,'[0-9]'))

 

but not getting proper result

four object is there 

1)job

2)job task

(master detail relationship between Job(master) and job task(Detail))


3)Schedule Template

4)Schedule Task

(master detail relationship between Schedule Template(master) and Schedule task(Detail))


all fields on job task and schedule tasks are same(except relational part)


one more thing is, there is lookup relationship between job(detail) and schedule template(master)...I want that when I select any schedule template on any job page then all the schedule task related to that particular schedule template should be copied into Job tAsk.(How to make trigger on job)


hi friends,

i have created a object named as Job,

i want to assign roles(different different users) for particular job record .

is it possible??

give me some idea about userrole... and how to user vf and apex in case of userrole?

Hi Friends,

i am getting problem when creating User with the help of visualforce page and Apex class(Apex class is used to view license and profiles))

problem here is about  Profile and  License type... since when we create user through manage users--> user if we select any particular license it shows profile only related to that license...(profile is dependent on license type we are selecting)...

but my page shows all licenses and profiles...

how to filter this??

 

here is my code--

 

</apex:page>

<apex:page standardController="User" extensions="CreateNewStaffAndUserExtension" tabStyle="Admin__c">
 
 
   
<!--    
<apex:sectionHeader title="Welcome" subtitle="{!User.Name}" help="/help/doc/user_ed.jsp?loc=help"></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="User Information" columns="2" collapsible="false">  
                
                  <apex:inputField value="{!User.User_Skills__c}" />
                  <apex:inputField value="{!User.IsActive}"/>
                  <apex:inputField value="{!User.FirstName}"/>
                  <apex:inputField value="{!User.Username}"/>
                  <apex:inputField value="{!User.LastName}"/>
                  <apex:inputField value="{!User.Email}"/>
                  <apex:inputField value="{!User.alias}"/>
                  <apex:inputField value="{!User.UserRoleId}"/>
                  
                 
                  </apex:pageBlockSection>
                 <!-- <apex:inputField value="{!User.UserType}"/> -->
            
           
            

              <!--  <apex:pageBlockSectionItem >
                    <apex:outputLabel value="User" for="usr"></apex:outputLabel>
                   
                    <apex:selectList value="{!selectedRoleId}" multiselect="false" size="1" id="selectedRoleId">
                       <apex:selectOptions value="{!userList}" />
                    </apex:selectList>
                    </apex:pageBlockSectionItem>
            
            -->
                    
                    
            <apex:pageBlockSection >
              <!--    <apex:inputField value="{!User.ProfileId}"/> -->
                   <apex:inputField value="{!User.Phone}"/>
                   <apex:inputField value="{!User.Extension}"/>
                   <apex:inputField value="{!User.Fax}"/>
                   <apex:inputField value="{!User.EmployeeNumber}"/>
                   <apex:inputField value="{!User.Title}"/>
                   <apex:inputField value="{!User.CompanyName}"/>
                   <apex:inputField value="{!User.Division}"/>
                   <apex:inputField value="{!User.Department}"/>
                   <apex:inputField value="{!User.CommunityNickName}"/>

                 <!--  <apex:inputField value="{!User.UserType}"/> -->
                   
                   <apex:inputField value="{!User.ReceivesInfoEmails}" />
                   </apex:pageBlocksection>
              
                    <apex:pageBlockSection columns="1" showHeader="false" title="License">
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="License" for="lic"></apex:outputLabel>
                    <apex:selectList id="mgr" value="{!User.UserType}" size="1" title="Manager">
                        <apex:selectOptions value="{!license}"></apex:selectOptions>
                    </apex:selectList>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Profile" for="pro"></apex:outputLabel>
                   
                    <apex:selectList value="{!User.ProfileId}" multiselect="false" size="1" id="selectedProfileId">
                       <apex:selectOptions value="{!profile}" />
                    </apex:selectList>
                    </apex:pageBlockSectionItem>
            </apex:pageBlockSection> 
            
              
              
               <apex:pageBlockSection title="Other Information" columns="1" collapsible="false">
                   <apex:inputField value="{!User.EmailEncodingKey}"/>
                   <apex:inputField value="{!User.TimeZoneSidKey}"/> 
                   <apex:inputField value="{!User.LocaleSidKey}"/>
                   <apex:inputField value="{!User.LanguageLocaleKey}"/>
               </apex:pageBlockSection>
               
            <!--   <apex:pageBlockSection columns="1" showHeader="false" title="License">
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="License" for="lic"></apex:outputLabel>
                    <apex:selectList id="mgr" value="{!User.UserType}" size="1" title="Manager">
                        <apex:selectOptions value="{!license}"></apex:selectOptions>
                    </apex:selectList>
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
            
            -->
            
              </apex:pageBlock>
              </apex:form>
   
 


    
Apex Class is-:
}

public class CreateNewStaffAndUserExtension {


   
    public Id accountId{get;set;}
    public String accountName{get;set;}

      public List<Account> accs{get;set;}

    private final User user;
    public CreateNewStaffAndUserExtension(ApexPages.StandardController controller)
    {
    
 
      this.user= (User)controller.getrecord();

    }
    
 
    public List<selectOption> getLicense()
    {
        List<selectOption> options = new List<selectOption>(); //new list for holding all of the picklist options
        options.add(new selectOption('', '- None -')); //add the first option of '- None -' in case the user doesn't want to select a value or in case no values are returned from query below
          for (UserLicense users :[SELECT Id,Name FROM UserLicense])  
          {    
                options.add(new selectOption(users.Id, users.Name)); //for all records found - add them to the picklist options
          }
        return options; //return the picklist options
    }
    
    public List<selectOption> getProfile() {
        List<selectOption> options1 = new List<selectOption>(); //new list for holding all of the picklist options
        options1.add(new selectOption('', '- None -')); //add the first option of '- None -' in case the user doesn't want to select a value or in case no values are returned from query below
     //   for (User users : [SELECT Id,UserType FROM User]) { //query for User records with System Admin profile
     for (Profile users1 :[SELECT Id,Name FROM Profile])  {    
                options1.add(new selectOption(users1.Id, users1.Name)); //for all records found - add them to the picklist options
        
        
        
        
        } 
        
        
        return options1; //return the picklist options 
   
   
    } 
  
    
 }

i have created a visualforce page (for creating user)... i have created a custom lookup on this vf page (lookup for accounts)...

and one more thing i have added .. i have taken a custom field on User (standard) object named as Account__c...

i want that whenever we will create new user by using this vf page... once account is selected this account name should be stored in Accouunt__c..

how to do??

 

here is my Code,

 

vf Page-: (CreateNewUser)

 

 

 

 

 

<apex:page standardController="User" extensions="CreateNewUserExtension">
 
<script language="javascript">
    var newWin=null;
    function openLookupPopup(name, id)
    {
        var url="/apex/AccountLookupPopup?namefield=" + name + "&idfield=" + id;
        newWin=window.open(url, 'Popup','height=500,width=600,left=100,top=100,resizable=no,scrollbars=yes,toolbar=no,status=no');
        if (window.focus)
        {
            newWin.focus();
        }
           
        return false;
    }
                 
    function closeLookupPopup()
    {
       if (null!=newWin)
       {
          newWin.close();
       } 
    }
</script> 

<apex:sectionHeader title="User Creation" subtitle="{!User.Name}" help="/help/doc/user_ed.jsp?loc=help"></apex:sectionHeader>
    <apex:form >
        <apex:pageBlock mode="edit">
        <apex:pageMessages />
            <apex:pageBlockButtons >
                    <apex:commandButton action="{!saveme}" value=" Save "></apex:commandButton>
                    <apex:commandButton action="{!cancel}" value="Cancel"></apex:commandButton>
                 </apex:pageBlockButtons>
             
              <apex:pageBlockSection title="User Information" columns="2" collapsible="false"> 
                <apex:pageBlockSectionitem >
                 <apex:outputLabel value="Account"/>
                 <apex:outputPanel >
                 <apex:inputHidden value="{!accountId}" id="targetId" />
                 <apex:inputText size="20" value="{!accountName}" id="targetName" onFocus="this.blur()" disabled="false"/>
                 <a href="#" onclick="openLookupPopup('{!$Component.targetName}', '{!$Component.targetId}'); return false"><apex:image value="{!$Resource.lookup_logo}" title="LookupLogo"/></a>
                 </apex:outputPanel>
                 </apex:pageBlockSectionitem>
                  <apex:inputField value="{!User.User_Type__c}" />
                  <apex:inputField value="{!User.FirstName}"/>
                  <apex:inputField value="{!User.LastName}"/>
                  <apex:inputField value="{!User.Username}"/>
                  <apex:inputField value="{!User.Email}"/>
                  <apex:inputField value="{!User.alias}"/>
                  <apex:inputField value="{!User.UserRoleId}"/> 
                  <apex:inputField value="{!User.IsActive}"/>
                  <apex:inputField value="{!User.UserType}"/>
                  <apex:inputField value="{!User.ProfileId}"/>
                   <apex:inputField value="{!User.Phone}"/>
                   <apex:inputField value="{!User.Extension}"/>
                   <apex:inputField value="{!User.Fax}"/>
                   <apex:inputField value="{!User.EmployeeNumber}"/>
                   <apex:inputField value="{!User.Title}"/>
                   <apex:inputField value="{!User.CompanyName}"/>
                   <apex:inputField value="{!User.Division}"/>
                   <apex:inputField value="{!User.Department}"/>
                   <apex:inputField value="{!User.CommunityNickName}"/>

                   <apex:inputField value="{!User.UserType}"/>
                  
                   <apex:inputField value="{!User.ReceivesInfoEmails}" />
              </apex:pageBlockSection>
             
               <apex:pageBlockSection title="Other Information" columns="1" collapsible="false">
                   <apex:inputField value="{!User.EmailEncodingKey}"/>
                   <apex:inputField value="{!User.TimeZoneSidKey}"/>
                   <apex:inputField value="{!User.LocaleSidKey}"/>
                   <apex:inputField value="{!User.LanguageLocaleKey}"/>
               </apex:pageBlockSection>
              </apex:pageBlock>
              </apex:form>
  
</apex:page>

 

 

Apex Class-:CreateNewUserExtension

 

public class CreateNewUserExtension {
  
    public Id accountId{get;set;}
    public String accountName{get;set;}
      public List<Account> accs{get;set;}
    private final User user;
    public CreateNewUserExtension(ApexPages.StandardController controller)
    {
   
      this.user= (User)controller.getrecord();

    }
   
   
     public PageReference saveme()
    {
 
    user.Username = user.Username;
    user.UserRoleId = user.UserRoleId;
    user.FirstName = user.FirstName;
    user.LastName = user.LastName;
    user.Email = user.Email;
    user.ProfileId = user.ProfileId;
    user.CompanyName = user.CompanyName;
    user.CommunityNickName = user.CommunityNickName;
    user.EmailEncodingKey = user.EmailEncodingKey;
    user.TimeZoneSidKey = user.TimeZoneSidKey;
    user.LocaleSidKey = user.LocaleSidKey;
    user.LanguageLocaleKey = user.LanguageLocaleKey;
    insert user;
    return null; 
  }

}

 

 

Cheers,

Amit Singh

Hi Friends,
I have created an object Purchase Order...
in Purchase Order Following are the Fields...
Name
Invoice Created (Picklist-: Yes,No,Partally)
Status (Picklist-: Sent,Open)
Amount (Currency)


Another Object Is-:
Invoice
Fields of Invoice are

Purchase Order (look up- PO is master)
Date (Date)
Amount (Currency)


i have override the Purchase order tab using visualforce page...
(i am using Page Block table in my Vf Page)

I Donot want to create Invoice From Invoice Tab...
i want to use command button in my Purchase Order Page Block Table...
so I will be able to create Invoice for Each PO...

Suppose i am creating any Invoice By click Create Button Next to any PO record...
i should get navigate to create Invoice Page (Where Purchase Order will be automatically filled)
( i am able to do this)

but I want that, Suppose Purchase Order Record (For which I want to Create Invoice),if its status field is Open then if I click on create Invoice button next to Purchase Oreder then I should Not allow to land to CreateNewInvoice Visualforce page... I should get message like "You can not create Invoice For this Purchase Order because its Status is Open"...

and if for any Purchase Oreder its status is Sent then after clicking create Invoice Button next to PO record I should land to Create New Invoice Visualforce...


How It can be Possible???

<apex:page controller="DisplayPOunderjobtabextension">

  <apex:form >
   <apex:pageBlock >
     
     
    
    
     <apex:commandButton action="{!CreatePO}" value="New Purchase Order" id="btn1"/> 
    
    <br/>
    <apex:pageBlockTable value="{!purchaseorder}" var="po">
    
    <apex:column headerValue="Action">

         
          <apex:commandButton value="Create Invoice" action="/apex/CreateInvoiceFromPO?id={!po.id}"/>
         </apex:column> 
    
    
      <apex:column headerValue="Name">
       <apex:outputLink tabindex="tab1" value="/apex/PODetailpage?id={!po.Id}">{!po.Name}</apex:outputLink>
      </apex:column>
      
      <apex:column headerValue="Invoice Created">
      <apex:outputField value="{!po.Invoice_Created__c}"/> 
      </apex:column>
            
       <apex:column headerValue="Status">
       <apex:outputField value="{!po.Status__c}"/>
      </apex:column>
      
      <apex:column headerValue="Total Amount">
       <apex:outputField value="{!po.Amount__c}"/>
      </apex:column>
      
    
    </apex:pageBlockTable>
    

   
  
    <apex:pageBlockSection rendered="{!purchaseorder.Size == 0}">
     <apex:pageBlockSectionItem >
      No records to display.
     
     </apex:pageBlockSectionItem>
    </apex:pageBlockSection>
    
   </apex:pageBlock>
   
  </apex:form>
</apex:page>




Apex Class


public class DisplayPOunderjobtabextension
{
public List<Purchase_Order__c> purchaseorder{get;set;} 
//public List<Purchase_Order__c> purchaseorder1{get;set;} 
public DisplayPOunderjobtabextension()
{
String theID = ApexPages.CurrentPage().getParameters().get('id');
purchaseorder = [Select id,Name,Due_Date__c,Issue_Date__c,job__c,Status__c,Total_Amount__c,Vendor__c,Approved_By_Staff__c,Invoice_Created__c from Purchase_Order__c where Job__c =: theID Order BY Name];
}

 public PageReference CreatePO()
    {
       String jobid;
       String theId=ApexPages.CurrentPage().getParameters().get('id');
       Job__c job = [Select Id from Job__c where id =: theID];
       jobid=job.Id;
       
      PageReference p = Page.CreateNewPurchaseOrder;
       p.setredirect(true);
     p.getParameters().put('jobid',theID); 
     return p;
       return null;
    }


}

 

Hi Friends,

i Have Created an object Estimate... and created a custom button Approve...and override it with a visualforce...

 

<apex:page standardController="Estimate_Line_Items__c" extensions="ApproveEstimateController" action="{!autoRun}">
  <apex:sectionHeader title="Auto-Running Apex Code"/>
  <apex:outputPanel >
      You tried calling Apex Code from a button.  If you see this page, something went wrong.  You should have
      been redirected back to the record you clicked the button from.
  </apex:outputPanel>
</apex:page>




Apec Class-->

public class ApproveEstimateController 
{
private final Estimate_Line_Items__c est;
    public ApproveEstimateController(ApexPages.StandardController controller)
    {
    this.est=(Estimate_Line_Items__c)controller.getRecord();
    }
 public PageReference autoRun() 
    {
    
         try
        {
        est.Approved__c=true;
        update est;
        }
        catch(System.DMLException e)
        {
        return null;
        }
    
     String theId = ApexPages.currentPage().getParameters().get('id');
     if (theId == null) 
        {
            // Display the Visualforce page's content if no Id is passed over
            return null;
        }
        PageReference pageRef = new PageReference('/' + theId);
        pageRef.setRedirect(true);
        return pageRef;
    
    }        

 
}

 

 

now the thing is that,,,when i am pressing this button from any Estimate Line Items Record page...

i want a popup window to ask "Do you want to Approve this Item"...after pressing yes it should process otherwise nothing shoul happen...

How it can be???


I Have Created an object as Job,in this object following are the fields,
start date (data type is date)
completion date (data type is date)
no. of dayas (data type is number)
now i want to use a field as due date...
and
due date = start date + number of days excluding sat / sun...
how can i use this???


I have taken one custom button "Approve" on my detail page. When i click on Approve button then i want to copy some field from that record into another object.

The another requirement is that after clicking on Approve button that particular record should not be available for editing.

 

How to do this?

Hi friends,

i Am facing problem with AutoNumber,

i have created object JobApllication(Master) and Review(Child)...

for review i have taken record name as Job Application number (Data Type is Autonumber)...

 

i have create two application JA1,JA2

 

in JA1,i have created two review ( R-1 and R-2 (Auto number ))

in JA2,i have created two review (now here i am getting R-3,R-4)...i want that for different-different  job application review should start with R-1

 

is it possible?

 

any suggestion how to solve this kind of issue?



Hi friends,

I ma creatin role with the help of vf and apex class...

and displaying roles in Visualforce page with the help of Apex class....

i want to give edit and delete functionalty on vf page... i have given the same...Edit is working properly...

Delete is also working fine... but while i want to delete a role for which any user is assigned it is Showing standard error..(i want to make it custom eg- you can not delete this role)...

 

can i do this???

 

this is my code..

 

public class RoleList

{

        public List<UserRole> list_role{get;set;}   

        public String message {get;set;} 

      public RoleList(ApexPages.StandardController controller)    

        {

         list_role=[Select Name From UserRole Order By Name];       

        }

   public PageReference del()

        {    String delname = ApexPages.CurrentPage().getParameters().get('id'); 

       try       

          {

          Database.delete(delname);  

          }

        catch(System.DMLException e)

        { 

       //         message = 'Whoops! An error occurred -- ';

      //         System.assert(false,message);

          System.assert(false, e.getMessage());        

         } 

  PageReference p=new PageReference('/apex/AdminListView?intFocus=6'); 

  p.setRedirect(true);

    return p;

    }
}

 

Hi friends,

i Am facing problem with AutoNumber,

i have created object JobApllication(Master) and Review(Child)...

for review i have taken record name as Job Application number (Data Type is Autonumber)...

 

i have create two application JA1,JA2

 

in JA1,i have created two review ( R-1 and R-2 (Auto number ))

in JA2,i have created two review (now here i am getting R-3,R-4)...i want that for different-different  job application review should start with R-1

 

is it possible?

 

any suggestion how to solve this kind of issue?

hi friends,

i have created two objects 1)Job 2)Job Task

and there is a master detail relationship between Job and JobTask...

i have created visualforc page to create new Job and Jobtask as well...

i am getting problem while deleting Job Task from its Detail page... Because after deleting it goes to standard list of jobtask...

i want that after deleting any jobtask it should go back to respected Job... i have written apex for this but not able to fetch id of master record...

could any one provide me code to override delete of job task

 

here is my code but not able to retrieve id ob JOB

 

 

public class DeleteJobTask
{
    private final JobTask__c objJT;
    public DeleteJobTask(ApexPages.StandardController controller)
    {
    this.objJT=(Holiday__c)controller.getrecord();
    }
     public PageReference checkDelete()
     {
        try
        {
        Database.delete(objJT);       
        }
        catch(System.DMLException e)
        {
        return null;
        }
        PageReference p =  new Pagereference('/apex/JobDetailPage?id=);
        p.setRedirect(true);
        return p;
     }

}

 

 

Hi,

I have created one vf page where i can create a User for my org. When i save a record after entering the required fields(Send EMail Notification functionality to that user is not works).

Is it because i am customizing Create User functionality on vf page?

Because when we create a User from Setup->Manage Users option salesforce automatically sends the email to that particular user.


Cheers,
Devendra S 

Hi Friends,

i am getting problem when creating User with the help of visualforce page and Apex class(Apex class is used to view license and profiles))

problem here is about  Profile and  License type... since when we create user through manage users--> user if we select any particular license it shows profile only related to that license...(profile is dependent on license type we are selecting)...

but my page shows all licenses and profiles...

how to filter this??

 

here is my code--

 

</apex:page>

<apex:page standardController="User" extensions="CreateNewStaffAndUserExtension" tabStyle="Admin__c">
 
 
   
<!--    
<apex:sectionHeader title="Welcome" subtitle="{!User.Name}" help="/help/doc/user_ed.jsp?loc=help"></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="User Information" columns="2" collapsible="false">  
                
                  <apex:inputField value="{!User.User_Skills__c}" />
                  <apex:inputField value="{!User.IsActive}"/>
                  <apex:inputField value="{!User.FirstName}"/>
                  <apex:inputField value="{!User.Username}"/>
                  <apex:inputField value="{!User.LastName}"/>
                  <apex:inputField value="{!User.Email}"/>
                  <apex:inputField value="{!User.alias}"/>
                  <apex:inputField value="{!User.UserRoleId}"/>
                  
                 
                  </apex:pageBlockSection>
                 <!-- <apex:inputField value="{!User.UserType}"/> -->
            
           
            

              <!--  <apex:pageBlockSectionItem >
                    <apex:outputLabel value="User" for="usr"></apex:outputLabel>
                   
                    <apex:selectList value="{!selectedRoleId}" multiselect="false" size="1" id="selectedRoleId">
                       <apex:selectOptions value="{!userList}" />
                    </apex:selectList>
                    </apex:pageBlockSectionItem>
            
            -->
                    
                    
            <apex:pageBlockSection >
              <!--    <apex:inputField value="{!User.ProfileId}"/> -->
                   <apex:inputField value="{!User.Phone}"/>
                   <apex:inputField value="{!User.Extension}"/>
                   <apex:inputField value="{!User.Fax}"/>
                   <apex:inputField value="{!User.EmployeeNumber}"/>
                   <apex:inputField value="{!User.Title}"/>
                   <apex:inputField value="{!User.CompanyName}"/>
                   <apex:inputField value="{!User.Division}"/>
                   <apex:inputField value="{!User.Department}"/>
                   <apex:inputField value="{!User.CommunityNickName}"/>

                 <!--  <apex:inputField value="{!User.UserType}"/> -->
                   
                   <apex:inputField value="{!User.ReceivesInfoEmails}" />
                   </apex:pageBlocksection>
              
                    <apex:pageBlockSection columns="1" showHeader="false" title="License">
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="License" for="lic"></apex:outputLabel>
                    <apex:selectList id="mgr" value="{!User.UserType}" size="1" title="Manager">
                        <apex:selectOptions value="{!license}"></apex:selectOptions>
                    </apex:selectList>
                </apex:pageBlockSectionItem>
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="Profile" for="pro"></apex:outputLabel>
                   
                    <apex:selectList value="{!User.ProfileId}" multiselect="false" size="1" id="selectedProfileId">
                       <apex:selectOptions value="{!profile}" />
                    </apex:selectList>
                    </apex:pageBlockSectionItem>
            </apex:pageBlockSection> 
            
              
              
               <apex:pageBlockSection title="Other Information" columns="1" collapsible="false">
                   <apex:inputField value="{!User.EmailEncodingKey}"/>
                   <apex:inputField value="{!User.TimeZoneSidKey}"/> 
                   <apex:inputField value="{!User.LocaleSidKey}"/>
                   <apex:inputField value="{!User.LanguageLocaleKey}"/>
               </apex:pageBlockSection>
               
            <!--   <apex:pageBlockSection columns="1" showHeader="false" title="License">
                <apex:pageBlockSectionItem >
                    <apex:outputLabel value="License" for="lic"></apex:outputLabel>
                    <apex:selectList id="mgr" value="{!User.UserType}" size="1" title="Manager">
                        <apex:selectOptions value="{!license}"></apex:selectOptions>
                    </apex:selectList>
                </apex:pageBlockSectionItem>
            </apex:pageBlockSection>
            
            -->
            
              </apex:pageBlock>
              </apex:form>
   
 


    
Apex Class is-:
}

public class CreateNewStaffAndUserExtension {


   
    public Id accountId{get;set;}
    public String accountName{get;set;}

      public List<Account> accs{get;set;}

    private final User user;
    public CreateNewStaffAndUserExtension(ApexPages.StandardController controller)
    {
    
 
      this.user= (User)controller.getrecord();

    }
    
 
    public List<selectOption> getLicense()
    {
        List<selectOption> options = new List<selectOption>(); //new list for holding all of the picklist options
        options.add(new selectOption('', '- None -')); //add the first option of '- None -' in case the user doesn't want to select a value or in case no values are returned from query below
          for (UserLicense users :[SELECT Id,Name FROM UserLicense])  
          {    
                options.add(new selectOption(users.Id, users.Name)); //for all records found - add them to the picklist options
          }
        return options; //return the picklist options
    }
    
    public List<selectOption> getProfile() {
        List<selectOption> options1 = new List<selectOption>(); //new list for holding all of the picklist options
        options1.add(new selectOption('', '- None -')); //add the first option of '- None -' in case the user doesn't want to select a value or in case no values are returned from query below
     //   for (User users : [SELECT Id,UserType FROM User]) { //query for User records with System Admin profile
     for (Profile users1 :[SELECT Id,Name FROM Profile])  {    
                options1.add(new selectOption(users1.Id, users1.Name)); //for all records found - add them to the picklist options
        
        
        
        
        } 
        
        
        return options1; //return the picklist options 
   
   
    } 
  
    
 }

I currently have a date field that displays a date 3 days from the date the form is opened. Here is the formula I used: TODAY() + 3

 

I would like to modify the formula to show a value of 3 business days instead of 3 days.  Can someone help?


Thanks in advance.

  • March 16, 2011
  • Like
  • 1