• NANCY1
  • NEWBIE
  • 0 Points
  • Member since 2011

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 32
    Questions
  • 56
    Replies

Hi All,

 

I am using the wrapper class to achieve the desired functionality..also i am referring the following link:

http://wiki.developerforce.com/index.php/Wrapper_Class

 

also, i am getting the following error:

Compile Error: Invalid field con for SObject RR__c at line 46 column 27

 

please suggest, where am i wrong....


public class AllRRs
{
   
    public class cRR
    { 
         public RR__c con {get; set;} 
         public Boolean selected {get; set;} 
 
         public cRR(RR__c c)
         {
          con = c;
          selected = false;
         } 
    }

   
   
   
    private Proposal__c rrdetail;
    public List<RR__c> propdetail {get; set;}
       
    public AllRRs(ApexPages.StandardController controller)
    {  
        rrdetail=(Proposal__c)controller.getrecord();
        rrdetail = [select id,name,Proposal_RRF__c from Proposal__c where id =: rrdetail.Id] ;
        propdetail = new List<RR__c>();
        RR__c rrlist = new RR__c();
        rrlist.RRF__c = rrdetail.Proposal_RRF__c;
        propdetail.add(rrlist);                             
    }
   
   
    public RR__c[] getRRRecords()
    {
        RR__c[] rrdetail = [select id,name,gPAC__c,RRF__c,Long_Term_Resource_Location__c,Priority__c,Required_Skill__c,RR_Status__c,RM_Phase__c from RR__c where RRF__c =:rrdetail.Proposal_RRF__c];
        return rrdetail;
       
    }
   
    
    public PageReference processSelected()
    {
        List<RR__c> selectedRRs = new List<RR__c>();
        for(RR__c cRR : getRRRecords())
        { 
          if(cRR.selected == true)
          { 
          selectedRRs.add(cRR.con); 
          } 
        }     
            for(RR__c con : selectedRRs)
            { 
              system.debug(con); 
            } 
            return null; 
    }
   
      
    
}

 

 

Hi All,

 

 

On the Proposal__c object page i have two lookup fields.. one for Resource_Requirement__c object and another for  RR__c object. while creating the new proposal as i'll select the value for Resource_Requirement__c object.. using the lookup field..i should be able to view all the RR__c records related to selected value of Resource_Requirement__c on the visualforce page.... 

 

 

public class AllRRs
{
    private Resource_Requirement__c rrdetail;
    public List<RR__c> propdetail;
       
    public AllRRs(ApexPages.StandardController controller)
    {
        rrdetail=(Resource_Requirement__c)controller.getre​cord();
        propdetail = new List<RR__c>();
        RR__c rrlist = new RR__c();
        rrlist.RRF__c = rrdetail.id;
        propdetail.add(rrlist);                        
    }
   
    public RR__c[] getCaseRecords()
    {
        RR__c[] rrdetail = [select id,name,gPAC__c,RRF__c,Long_Term_Resource_Location​__c,Priority__c,Required_Skill__c,RR_Status__c,RM_​Phase__c from RR__c where RRF__c =:rrdetail.id];
        return rrdetail;
    }
}

Hi,

 

I need to create the visualforce page that should display all the records based on the lookup field value selected. Please guide me.

 

 

Thanks

Hi,

 

I need to create the visualforce page that should display all the records based on the lookup field value selected. Plese guide me.

 

 

Thanks

Hi,

 

I have a lookup field on RR__c and Proposal__c for another object Employee__c. Based on the field value in Proposal object i need to update the RR__c record. I am using the following code..which is throwing an error

Too many SOQL queries: 101

 

trigger updateEmpinRR on Proposal__c (after insert,after update)
{

        List < Id > rrIds = new List < Id >();
        List < Id > proposalIds = new List < Id >();
        for ( Proposal__c  c: Trigger.New )
        {
            proposalIds.add( c.Id );
            rrIds.add(c.Proposal_RR__c);
        }
        List<RR__c> opps = [select id, Selected_Employee__c from RR__c where id in :rrIds];
        Map < Id ,RR__c > empmap = new Map < Id , RR__c >();
        for ( RR__c  a : opps   )
        {
            empmap.put( a.Id, a);
        }
        List < RR__c > EmpToUpdate = new List < RR__c >();
        for(Proposal__c c: Trigger.New)
        {
            RR__c ac = empmap.get( c.Proposal_RR__c);        
            if ( ac == null )
            {   
                  continue;
            }
            If (c.Status__c == 'Selected-New')
            {
               ac.Selected_Employee__c = c.RMG_Employee_Code__c;   
               EmpToUpdate.add( ac );
            }
            else
            {
              ac.Selected_Employee__c = null;   
              EmpToUpdate.add( ac );
            }
     
                     
            
                        
        }
        upsert EmpToUpdate;     
}

Hi All,

 

Sorry to mark it urgent, as i need to implement this soon...

 

I have a custom object with Master detail Relationship, now i want to make this field as lookp field (reason: i may not have the master record each time for the detail record). Please let me know the way of converting the master field to Lookup, or any other Data Type.

 

or else, is there any way to to mark the Master Detail field as non-mandatory on the detail objects page layout

 

Please let me know..

 

Thanks

 

 

 

 

 

Hi,

 

I have a master detail relationship between Opportunity( as master) and Custom object (as detail).

 

I want to update all the detail records, if i change / update any detail record. I mean all the detail records should contain same value. If i am changing any record, that should get changed other detail records as well..

 

trigger updateallRequisitions on Opportunity (after update) {
    List < Id > OppsIds = new List < Id >();
    List < Id > RRIds = new List < Id >();
    for(Opportunity rem: Trigger.New) {    
        if(rem.test__c != 'Closed'){    
           List<RR__c> proObj = [select p.Id,p.Bill_Rate__c from RR__c p where p.Opportunity__c =:rem.Id];
           if(proObj.size() > 0){
               for(RR__c pc: proObj ){
                   pc.Bill_Rate__c = rem.test__c ;
                   update pc;
               }
           }          
        }      
    }
}

 

 

 

Thanks

Hi,

 

I am able to create single record for the custom detail object using the VF page, how to define the number of records should get created on VF page itself, so that when i hit save button the defined number of records should get created??

 

my Apex Class:

public class OrderEntry 
{
    public List<RR__c> ords {get; set;}
    private final Opportunity parOrd;
    public OrderEntry(ApexPages.StandardController​ myController) {
        parOrd=(Opportunity)myController.getrecord​();
        ords = new List<RR__c>();
        RR__c LitOrd = new RR__c();
        LitOrd.Opportunity__c = parOrd.id;
        ords.add(LitOrd);}

    public void addrow() {
        RR__c LitOrd = new RR__c();
        LitOrd.Opportunity__c = parOrd.id;
        ords.add(LitOrd);}
            
    public void removerow(){
        Integer i = ords.size();
        ords.remove(i-1);}
            
    public PageReference save() {
         insert ords;
        PageReference parrec = new PageReference('​/'+ parOrd.id);
        parrec.setRedirect(true);
        return parrec; }
}

 

 

VF Page:

<apex:page standardController="Opportunity" extensions="OrderEntry">
    <apex:form >
    <apex:pageBlock title="Create Requisitions against Opportunities" >
                <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}" rerender="error" />
            </apex:pageBlockButtons>
            <apex:pageBlockTable value="{!ords}" var="a" id="table">
                <apex:column headerValue="Opportunity Name">
                    <apex:inputField value="{!a.Opportunity__c}"/>
                </apex:column>               
               
            </apex:pageBlockTable>
    <apex:pageblockButtons location="bottom">
        <div style="text-align:right;margin-right:30px;font-wei​ght:bold;">
            <apex:commandLink value="Add Row" action="{!addRow}" rerender="table,error" immediate="true" />
&nbsp; | &nbsp;
<apex:commandLink value="Remove Row" action="{!removeRow}" rerender="table,error" immediate="true" />               

        </div>
    </apex:pageblockButtons> 
    </apex:pageBlock>
    </apex:form>
</apex:page>

 

Hi,

 

I am able to create single record for the custom detail object using the VF page, how to define the number of records should get created on VF page itself, so that when i hit save button the defined number of records should get created??

 

my Apex Class:

public class OrderEntry 
{
    public List<RR__c> ords {get; set;}
    private final Opportunity parOrd;
    public OrderEntry(ApexPages.StandardController myController) {
        parOrd=(Opportunity)myController.getrecord();
        ords = new List<RR__c>();
        RR__c LitOrd = new RR__c();
        LitOrd.Opportunity__c = parOrd.id;
        ords.add(LitOrd);}

    public void addrow() {
        RR__c LitOrd = new RR__c();
        LitOrd.Opportunity__c = parOrd.id;
        ords.add(LitOrd);}
            
    public void removerow(){
        Integer i = ords.size();
        ords.remove(i-1);}
            
    public PageReference save() {
         insert ords;
        PageReference parrec = new PageReference('/'+ parOrd.id);
        parrec.setRedirect(true);
        return parrec; }
}

 

 

VF Page:

<apex:page standardController="Opportunity" extensions="OrderEntry">
    <apex:form >
    <apex:pageBlock title="Create Requisitions against Opportunities" >
                <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}" rerender="error" />
            </apex:pageBlockButtons>
            <apex:pageBlockTable value="{!ords}" var="a" id="table">
                <apex:column headerValue="Opportunity Name">
                    <apex:inputField value="{!a.Opportunity__c}"/>
                </apex:column>               
               
            </apex:pageBlockTable>
    <apex:pageblockButtons location="bottom">
        <div style="text-align:right;margin-right:30px;font-weight:bold;">
            <apex:commandLink value="Add Row" action="{!addRow}" rerender="table,error" immediate="true" />
&nbsp; | &nbsp;
<apex:commandLink value="Remove Row" action="{!removeRow}" rerender="table,error" immediate="true" />               

        </div>
    </apex:pageblockButtons> 
    </apex:pageBlock>
    </apex:form>
</apex:page>
               

Hi All,

 

I have a custom object i.e. Project with a custom field Project Team (that contains the employee code).

Now, in the Standard User object.. i have a Custom field Employee Code.

 

I want to give access to the logged in user, of only those project records where the User's employee code contains/matches with the Project record.

 

its something User authencation kind of stuff...based on the custom fields...

 

I am running in big time issue.. please suggest..Thanks

Hi All,

 

I have a lookup field Proposal_RRF__c from (Resource_Requirement__c object) in the Custom object i.e.  Proposal__c, based on this fields value selection  i want to extract RRF_Request_By__c field from Resource_Requirement__c object but i am getting the following error:

 

RRFDetails: execution of AfterUpdate caused by: System.FinalException: Record is read-only:

 

Trigger Code:

 

trigger RRFDetails on Proposal__c (after update)
{
    List<Id> proids = new List<Id>();
    Map<Id,Id> promap = new Map<Id,Id>();
    for(Proposal__c c : Trigger.new) {
        proids.add(c.id);
    }
    List<Resource_Requirement__c> pros = [SELECT id, RRF_Request_By__c from Resource_Requirement__c where ID IN :proids];
    for(Resource_Requirement__c o : pros) {
        promap.put(o.id,o.RRF_Request_By__c);
    }
   
    for(Proposal__c c : Trigger.new) {
      //if(c.Proposal_RRF__c != null)
        //{
        c.RRF_Requested_By__c = promap.get(c.RRF_Requested_By__c);
        //}
    }
}

 

Hi,

 

Using the below given trigger i am able to prevent user from being creating a contact with an existing Email Address, but i also need to check this while changing an existing contact's email address... i mean even for an existing contacts if the user try to change an email address with an existing email address.. the trigger should get fired??

 

 

 

trigger ContactDuplicateTrigger on Contact (before insert) {
   for (Contact c : Trigger.new){
     
      Contact[] contacts= [select id from Contact where Email = :c.Email];
     
      if (contacts.size() > 0) {
          c.Email.addError('Contact cannot be created - Contact already exists');
      }   
   }
}

 

 

  • April 17, 2011
  • Like
  • 0

Hi All,

 

I have a trigger for which i have written a test class.. but that covers only 33% code area.. how can i make it more then 75%...

 

My Apex Trigger:

 

trigger proposalstatus on Proposal__c (after update, after insert, after delete)

    if (Trigger.isDelete){
        /* This will always have only one Id*/
        List < Id > empmasterIds = new List < Id >();
        List < Id > proposalIds = new List < Id >();
   
        for ( Proposal__c  c: Trigger.old)
        {
            proposalIds.add( c.Id );
            empmasterIds.add( c.RMG_Employee_Code__c);
        }
       
        /* This will contain the aggregated proposal status of the employee*/
        List<RMG_Employee_Master__c> opps = [select id, Proposal_Status__c, Temp_Proposal_Status__c from RMG_Employee_Master__c where id in :empmasterIds];
   
        /* Mapping between employeeId and employee*/
        Map < Id ,RMG_Employee_Master__c > empmap = new Map < Id , RMG_Employee_Master__c >();
        for ( RMG_Employee_Master__c  a : opps   )
        {
            empmap.put( a.Id, a);
        }

        /* List of employees to be updated. This will have only one employee - the current employee.*/
        List < RMG_Employee_Master__c > EmpToUpdate = new List < RMG_Employee_Master__c >();
   
        /* Get the status of the new proposal */
        for(Proposal__c c: Trigger.old)
        {
           system.debug('Inside Proposal Loop 2');
           /* Fetch the current employee */
           RMG_Employee_Master__c ac = empmap.get( c.RMG_Employee_Code__c );        
           if (ac == null)
           {   
               continue;
           }
       
           system.debug('----------->'+c.Status__c);
           /* Get all proposals for this employee and mark them as closed. */
           String futureProposalStatus = 'Unassigned';
           List<Proposal__c> proObj = [select Id,Status__c,RMG_Employee_Code__c from Proposal__c where Id !=:c.Id and RMG_Employee_Code__c =:ac.Id ];
           for(Proposal__c pc: proObj )
           {
                if ((pc.Status__c == 'Proposed') && (futureProposalStatus == 'Proposed')){
                    futureProposalStatus = 'AUP';
                } else if ((pc.Status__c == 'Proposed')
                        || (pc.Status__c == 'Blocked')
                        || (pc.Status__c == 'Selected-New')
                        || (pc.Status__c == 'Selected-Extended')){
                    futureProposalStatus = pc.Status__c;
                }
           }//for
           ac.Proposal_Status__c = futureProposalStatus;
           ac.Temp_Proposal_Status__c = futureProposalStatus;
           EmpToUpdate.add(ac);
           system.debug('Inside Proposal Loop 2: '+futureProposalStatus);
         }//For Trigger.old
         upsert EmpToUpdate;      
    } else {
        /* This will always have only one Id*/
        List < Id > empmasterIds = new List < Id >();
        List < Id > proposalIds = new List < Id >();

        for ( Proposal__c  c: Trigger.New )
        {
            proposalIds.add( c.Id );
            empmasterIds.add( c.RMG_Employee_Code__c);
        }
   
        /* This will contain the aggregated proposal status of the employee*/
        List<RMG_Employee_Master__c> opps = [select id, Proposal_Status__c,Temp_Proposal_Status__c from RMG_Employee_Master__c where id in :empmasterIds];
   
        /* Mapping between employeeId and employee*/
        Map < Id ,RMG_Employee_Master__c > empmap = new Map < Id , RMG_Employee_Master__c >();
        for ( RMG_Employee_Master__c  a : opps   )
        {
            empmap.put( a.Id, a);
        }

        /* List of employees to be updated. This will have only one employee - the current employee.*/
        List < RMG_Employee_Master__c > EmpToUpdate = new List < RMG_Employee_Master__c >();
   
        /* Get the status of the new proposal */
        for(Proposal__c c: Trigger.New)
        {
            /* Fetch the current employee */
            RMG_Employee_Master__c ac = empmap.get( c.RMG_Employee_Code__c );        
            if ( ac == null )
            {   
                  continue;
            }
       
            /* If the new proposal's status is not closed, then set the Aggregated proposal status as the status
             of the new Proposal, else mark it as unassigned. */
       
            If (c.Status__c != 'Closed')
            {
               ac.Proposal_Status__c = c.Status__c;   
               ac.Temp_Proposal_Status__c = c.Status__c;
               EmpToUpdate.add( ac );
            }
            else
            {
               ac.Proposal_Status__c = 'Unassigned';
               ac.Temp_Proposal_Status__c = 'Unassigned';
               EmpToUpdate.add( ac );
            }
       
            /* If the new Proposal's status is equal to 'Blocked' or 'Selected' then close rest of the proposals. */
            if((c.Status__c == 'Selected-New') || (c.Status__c == 'Blocked') || (c.Status__c == 'Selected-Extended'))
            {
                system.debug('----------->'+c.Status__c);
                /* Get all proposals for this employee and mark them as closed. */
                List<Proposal__c> proObj = [select Id,Status__c,RMG_Employee_Code__c from Proposal__c where Id !=:c.Id and RMG_Employee_Code__c =:ac.Id ];
                for(Proposal__c pc: proObj )
                {
                   system.debug('BEFORE STATUS--->'+pc.Status__c);
         
                   if ((pc.Status__c != 'Closed')
                       && (pc.Status__c != 'Likely Extension')
                       && (pc.Status__c != 'Blocked')
                       && (pc.Status__c != 'Selected-New')
                       && (pc.Status__c != 'Selected-Extended')){            
                       pc.Status__c = 'Closed';
                       system.debug('AFTER STATUS--->'+pc.Status__c);
                       update pc;
                   }//if
                }//for
             }//if
         }//For Trigger.New
         upsert EmpToUpdate;      
     }//Else
}//End of Trigger

  • April 04, 2011
  • Like
  • 0

Hi,

 

I have a master field that need to get updated based on all detail records.

 

In the detail records i have the status field, if for all the detail records value of the Status field is "Closed" then the master field value should also be closed.. (i.e. the value of the master field will be "closed" only if all detail records are "closed")

 

how can i achieve that...

 

  • March 21, 2011
  • Like
  • 0

Hi ,

 

I have a master object with tthe date field Test__c. And i have multiple detail records associated with the master record.

Among all the detail record i need to catch the largest date and copy it to the master field.

 

Please suggest how can i achieve this with the help of trigger??

 

  • March 14, 2011
  • Like
  • 0

Hi,

 

I want to convert leads to an opportunity. Please let us know how to map between the Lead's Custom Fields to Opportunities Standard fields and Lead's Standard Fields with Opportunities Custom Fields.

 

Thanks

  • March 07, 2011
  • Like
  • 0

Hi All,

 

I have Two Objects with Master Detail relationship.

 

I have written a trriger on the Detail object to update a field say 'Field A' of the Master object. The Same field 'Field A' is also getting updated with a Workflow on the Master Object. Now, once my workflow's condition gets satified. my field gets updated.. i am ok with that...

 

But the problem comes when my workflow condition gets failed.. i want the value from the Trigger should get now updated..

 

 

I mean once my workflow condition gets False.. the trigger should get fire to update that field...

 

The trigger on the detail object is written on After Insert, After Delete events..

 

I hope that i am able to explain the problem....

 

please suggest,..

 

 

 

 

 

  • February 21, 2011
  • Like
  • 0

Hi,

 

I have a Master object and a Detail object. In the Master object i have a Text field that is getting updated based on the child object records.

 

Also, the same Master field is also getting updated based on the workflow.

 

No, my question is if i have set a value of taht field using the workflow once my workflow condition gets dissatified my the value set by the trigger should get updated..

 

Please let me know how can i do this..

  • February 16, 2011
  • Like
  • 0

Hi,

 

Master Object > RMG_Employee_Master__c

Detail object > Proposal__c

Detail Object Field > Status__c

 

Under this master object, I have number of detail object records.

 

The functionality is something like when I create a new record in the Detail Object where Status__c is not equal to ‘Proposed’, than for all the other records [already created] Status__c should become ‘Closed’.

 

Please let me know is this can be achieved?? Thanks

  • January 27, 2011
  • Like
  • 0

Hi,

 

I need to constantly update the master field based on the detail field value i.e. a picklist field with multiple values.

 

Master Object > RMG_Employee_Master__c

Master Object Field > Proposal_Status__c

 

Child Object > Proposal__c

Child Object Field > Status__c

 

 

I am able to update the master field based on the detail field value. But how can  loop through the multiple detail records to set the value of one master field:

 

trigger proposalstatus on Proposal__c (after insert,after update)
{

   List<RMG_Employee_Master__c> opps = new List<RMG_Employee_Master__c>();
   List<ID> masterIds = new List<ID>();
   Map<ID, String> childDetailMap = new Map<ID, String>();
  
   for(Proposal__c c: Trigger.new)
    {
      masterIds.add(c.RMG_Employee_Code__c);
      childDetailMap.put(c.RMG_Employee_Code__c, (c.Status__c));
    }
    opps = [select id, Proposal_Status__c from RMG_Employee_Master__c where id in :masterIds];
 
   for(RMG_Employee_Master__c rem: opps)
    {
      rem.Proposal_Status__c = childDetailMap.get(rem.id);
    }
    if(opps.size() > 0)
    {
     Update opps;
     }
}

  • January 27, 2011
  • Like
  • 0

Hi All,

 

 

On the Proposal__c object page i have two lookup fields.. one for Resource_Requirement__c object and another for  RR__c object. while creating the new proposal as i'll select the value for Resource_Requirement__c object.. using the lookup field..i should be able to view all the RR__c records related to selected value of Resource_Requirement__c on the visualforce page.... 

 

 

public class AllRRs
{
    private Resource_Requirement__c rrdetail;
    public List<RR__c> propdetail;
       
    public AllRRs(ApexPages.StandardController controller)
    {
        rrdetail=(Resource_Requirement__c)controller.getre​cord();
        propdetail = new List<RR__c>();
        RR__c rrlist = new RR__c();
        rrlist.RRF__c = rrdetail.id;
        propdetail.add(rrlist);                        
    }
   
    public RR__c[] getCaseRecords()
    {
        RR__c[] rrdetail = [select id,name,gPAC__c,RRF__c,Long_Term_Resource_Location​__c,Priority__c,Required_Skill__c,RR_Status__c,RM_​Phase__c from RR__c where RRF__c =:rrdetail.id];
        return rrdetail;
    }
}

Hi,

 

I need to create the visualforce page that should display all the records based on the lookup field value selected. Please guide me.

 

 

Thanks

Hi,

 

I need to create the visualforce page that should display all the records based on the lookup field value selected. Plese guide me.

 

 

Thanks

Hi,

 

I have a lookup field on RR__c and Proposal__c for another object Employee__c. Based on the field value in Proposal object i need to update the RR__c record. I am using the following code..which is throwing an error

Too many SOQL queries: 101

 

trigger updateEmpinRR on Proposal__c (after insert,after update)
{

        List < Id > rrIds = new List < Id >();
        List < Id > proposalIds = new List < Id >();
        for ( Proposal__c  c: Trigger.New )
        {
            proposalIds.add( c.Id );
            rrIds.add(c.Proposal_RR__c);
        }
        List<RR__c> opps = [select id, Selected_Employee__c from RR__c where id in :rrIds];
        Map < Id ,RR__c > empmap = new Map < Id , RR__c >();
        for ( RR__c  a : opps   )
        {
            empmap.put( a.Id, a);
        }
        List < RR__c > EmpToUpdate = new List < RR__c >();
        for(Proposal__c c: Trigger.New)
        {
            RR__c ac = empmap.get( c.Proposal_RR__c);        
            if ( ac == null )
            {   
                  continue;
            }
            If (c.Status__c == 'Selected-New')
            {
               ac.Selected_Employee__c = c.RMG_Employee_Code__c;   
               EmpToUpdate.add( ac );
            }
            else
            {
              ac.Selected_Employee__c = null;   
              EmpToUpdate.add( ac );
            }
     
                     
            
                        
        }
        upsert EmpToUpdate;     
}

Hi All,

 

Sorry to mark it urgent, as i need to implement this soon...

 

I have a custom object with Master detail Relationship, now i want to make this field as lookp field (reason: i may not have the master record each time for the detail record). Please let me know the way of converting the master field to Lookup, or any other Data Type.

 

or else, is there any way to to mark the Master Detail field as non-mandatory on the detail objects page layout

 

Please let me know..

 

Thanks

 

 

 

 

 

Hi,

 

I have a master detail relationship between Opportunity( as master) and Custom object (as detail).

 

I want to update all the detail records, if i change / update any detail record. I mean all the detail records should contain same value. If i am changing any record, that should get changed other detail records as well..

 

trigger updateallRequisitions on Opportunity (after update) {
    List < Id > OppsIds = new List < Id >();
    List < Id > RRIds = new List < Id >();
    for(Opportunity rem: Trigger.New) {    
        if(rem.test__c != 'Closed'){    
           List<RR__c> proObj = [select p.Id,p.Bill_Rate__c from RR__c p where p.Opportunity__c =:rem.Id];
           if(proObj.size() > 0){
               for(RR__c pc: proObj ){
                   pc.Bill_Rate__c = rem.test__c ;
                   update pc;
               }
           }          
        }      
    }
}

 

 

 

Thanks

Hi,

 

I am able to create single record for the custom detail object using the VF page, how to define the number of records should get created on VF page itself, so that when i hit save button the defined number of records should get created??

 

my Apex Class:

public class OrderEntry 
{
    public List<RR__c> ords {get; set;}
    private final Opportunity parOrd;
    public OrderEntry(ApexPages.StandardController​ myController) {
        parOrd=(Opportunity)myController.getrecord​();
        ords = new List<RR__c>();
        RR__c LitOrd = new RR__c();
        LitOrd.Opportunity__c = parOrd.id;
        ords.add(LitOrd);}

    public void addrow() {
        RR__c LitOrd = new RR__c();
        LitOrd.Opportunity__c = parOrd.id;
        ords.add(LitOrd);}
            
    public void removerow(){
        Integer i = ords.size();
        ords.remove(i-1);}
            
    public PageReference save() {
         insert ords;
        PageReference parrec = new PageReference('​/'+ parOrd.id);
        parrec.setRedirect(true);
        return parrec; }
}

 

 

VF Page:

<apex:page standardController="Opportunity" extensions="OrderEntry">
    <apex:form >
    <apex:pageBlock title="Create Requisitions against Opportunities" >
                <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}" rerender="error" />
            </apex:pageBlockButtons>
            <apex:pageBlockTable value="{!ords}" var="a" id="table">
                <apex:column headerValue="Opportunity Name">
                    <apex:inputField value="{!a.Opportunity__c}"/>
                </apex:column>               
               
            </apex:pageBlockTable>
    <apex:pageblockButtons location="bottom">
        <div style="text-align:right;margin-right:30px;font-wei​ght:bold;">
            <apex:commandLink value="Add Row" action="{!addRow}" rerender="table,error" immediate="true" />
&nbsp; | &nbsp;
<apex:commandLink value="Remove Row" action="{!removeRow}" rerender="table,error" immediate="true" />               

        </div>
    </apex:pageblockButtons> 
    </apex:pageBlock>
    </apex:form>
</apex:page>

 

Hi,

 

I am able to create single record for the custom detail object using the VF page, how to define the number of records should get created on VF page itself, so that when i hit save button the defined number of records should get created??

 

my Apex Class:

public class OrderEntry 
{
    public List<RR__c> ords {get; set;}
    private final Opportunity parOrd;
    public OrderEntry(ApexPages.StandardController myController) {
        parOrd=(Opportunity)myController.getrecord();
        ords = new List<RR__c>();
        RR__c LitOrd = new RR__c();
        LitOrd.Opportunity__c = parOrd.id;
        ords.add(LitOrd);}

    public void addrow() {
        RR__c LitOrd = new RR__c();
        LitOrd.Opportunity__c = parOrd.id;
        ords.add(LitOrd);}
            
    public void removerow(){
        Integer i = ords.size();
        ords.remove(i-1);}
            
    public PageReference save() {
         insert ords;
        PageReference parrec = new PageReference('/'+ parOrd.id);
        parrec.setRedirect(true);
        return parrec; }
}

 

 

VF Page:

<apex:page standardController="Opportunity" extensions="OrderEntry">
    <apex:form >
    <apex:pageBlock title="Create Requisitions against Opportunities" >
                <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!save}" rerender="error" />
            </apex:pageBlockButtons>
            <apex:pageBlockTable value="{!ords}" var="a" id="table">
                <apex:column headerValue="Opportunity Name">
                    <apex:inputField value="{!a.Opportunity__c}"/>
                </apex:column>               
               
            </apex:pageBlockTable>
    <apex:pageblockButtons location="bottom">
        <div style="text-align:right;margin-right:30px;font-weight:bold;">
            <apex:commandLink value="Add Row" action="{!addRow}" rerender="table,error" immediate="true" />
&nbsp; | &nbsp;
<apex:commandLink value="Remove Row" action="{!removeRow}" rerender="table,error" immediate="true" />               

        </div>
    </apex:pageblockButtons> 
    </apex:pageBlock>
    </apex:form>
</apex:page>