• BlairB
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 2
    Likes Received
  • 0
    Likes Given
  • 12
    Questions
  • 17
    Replies
Hello,

I have a custom object (Warehouse Visit) that is the child record of Contact. I'd like to click a button on the Warehouse Visit tab where multiple records can be created on one Visualforce page. Basically, I'd like staff to be able to log multiple visits on one page rather than add them one by phone.

On the VF page, I'd like a link that says "add" to allow staff to add multiple rows for each record (3-4 fields). At the end of each row, I want a Remove or X link to remove that row if it was created in error. Then, on save, I'd like it to redirect back to the Warehouse Visit tab. 

I haven't started building the VF page yet, but I'd like to enter about 4 fields, including a lookup to the Contact, a couple of date/time fields, and maybe a checkbox or picklist. 

I have started with this Apex class code, based on a previous button I had help developing, but I'm getting an error. Can anyone help fix this code?

public class WarehouseVisitController {
    public List<Warehouse_Visit__c> wvRecord{get; set;}
    public Integer wvIndex {get; set;}

    public WarehouseVisitController  (){
        wvRecord = new List<Warehouse_Visit__c>();
        wvRecord.add(new Warehouse_Visit__c);
    } #this is where the error is happening
    public void addWarehouseVisit () {
        wvRecord.add(new Warehouse_Visit__c);
    }
    public void removeWarehouseVisit() {
        wvIndex = Integer.valueOf(ApexPages.currentPage().getParameters().get('wvIndex'));
        wvRecord.remove(wvIndex);
    }
    public PageReference save() {
        upsert wvRecord;
        PageReference page = new PageReference('/');
        return page;
    }
    public PageReference cancel() {
        PageReference page = new PageReference('/' );
        return page;
    }
}

 

Hello all,

I've been trying for awhile to create a list button that will allow the creation of multiple child records of the same parent record on one Visualforce page (rather than clicking save and new over and over). I need to pass the parent ID and assign a record type, and I'd prefer that happen without the user having to do anything other than click the button on the related list. My visualforce page works in that if I preview it, I can see each field in a column, and the "add" link is working to add new rows. However, the parent ID isn't getting passed, I can't figure out how to assign the record type ID, and the "x" link to delete a row isn't working.

I've posted on the forum about this multiple times, but have not received many replies.

This would be a huge help for the organizations I work with, and I'd be willing to pay for a few hours of someone's time to help me get the code right. Any one interested in helping me out?

  • February 04, 2020
  • Like
  • 0
Hi,

I am attempting to create a visualforce page that will be accessed from a button on a related list. This button will allow users to add multiple child records related to the parent record. 

The parent object is Sessions__c and the child object is Class_Enrollments__c. I want users to be able to click the button and be routed to a VF page where they can add child records on one page.

I am running into three issues:

1) Whenever I try to save the record, I get the following error:

System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Session]: [Session]
Error is in expression '{!insertClass_Enrollments}' in component <apex:commandButton> in page add_class_enrollments: Class.AddingEnrollmentsController.insertClass_Enrollments: line 14, column 1
Class.AddingEnrollmentsController.insertClass_Enrollments: line 14, column 1

So, the parent record ID is not being passed to the child records.

2) I want to assign the record type ID to new child records. Child records will have the same record type for this particular page/button.

3) The "Delete" row function is not working

Below is my controller extension:

User-added image
VF page:

User-added image
Finally, all of this is being accessed via a list button that has the following URL:

/apex/Add_Class_Enrollments?SessionId={!Class_Enrollments__c.SessionId__c}

Help appreciated!

 
  • November 18, 2019
  • Like
  • 0
Hello,

I have created a Visualforce page where users can add multiple child records at once. I want to add a list button to the related list on the parent object. Both are custom objects.The parent object in this scenario Sessions__c and the child object is Class_Enrollments__c. 

Despite trying to use a Standard Controller + Extension, the VF page is not appearing in the Content when trying to add a custom list button. So, instead, I am passing it through the URL (/apex/Add_Class_Enrollments?class_enrollmentsId={!Class_Enrollments__c.Id}).

The below code is not working to pass the Session ID to the Class Enrollment records. The button opens the VF page and the VF page looks correct. However, when I try to save, it gives this error: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Session]: [Session]
Error is in expression '{!insertClass_Enrollments}' in component <apex:commandButton> in page add_class_enrollments: Class.AddingEnrollmentsController.insertClass_Enrollments: line 14, column 1

Here is my VF code:

<apex:page standardController="Class_Enrollments__c" recordSetVar="enrollments" extensions="AddingEnrollmentsController">
    <apex:form >
        <apex:variable var="rowNum" value="{!0}"  />
        <apex:pageBlock >
            <apex:variable var="rowNum" value="{!0}"  />  
            <apex:pageBlockTable value="{!Class_EnrollmentsList}" var="CE">
                <apex:facet name="footer">
                    <apex:commandLink value="Add" action="{!insertRow}"/>
                </apex:facet>
                <apex:column headerValue="Youth Name">
                    <apex:inputField value="{!CE.Youth_Name__c}"/>
                </apex:column>
                <apex:column headerValue="Works Wonders Record">
                    <apex:inputField value="{!CE.Works_Wonders_Youth_Name__c}"/>
                </apex:column>
                <apex:column headerValue="Attendance">
                    <apex:inputField value="{!CE.Attendance__c}"/>
                </apex:column>
                 <apex:column headerValue="Participation Note">
                    <apex:inputField value="{!CE.Participation_Note__c}"/>
                </apex:column>         
                <apex:column headerValue="Delete" >
                    <apex:commandLink style="font-size:15px; font-weight:bold; text-align:center;color:red;" value="X" action="{!delRow}">
                        <apex:param value="{!rowNum}" name="index" />
                    </apex:commandLink>
                    <apex:variable var="rowNum" value="{!rowNum+1}"/>
                </apex:column>          
            </apex:pageBlockTable>
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!insertClass_Enrollments}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller extension:

public class AddingEnrollmentsController {
    Id SessionId;
    public List<Class_Enrollments__c> class_enrollmentsList {get;set;}
    public Integer rowNum{get;set;}
    
    public AddingEnrollmentsController(ApexPages.StandardSetController controller){
       Id enrollmentsId = ApexPages.currentPage().getParameters().get('enrollmentsId');
       SessionId=ApexPages.currentPage().getParameters().get('SessionId');
       class_enrollmentsList = new List<Class_Enrollments__c>();  
       class_enrollmentsList.add(new Class_Enrollments__c());      
    }
    
    public pagereference insertClass_Enrollments(){
    insert class_enrollmentsList;
    Pagereference page=new pagereference('/'+SessionId);
    Return page;
}
    
    public void insertRow(){
        class_enrollmentsList.add(new Class_Enrollments__c()); 
    }

    public void delRow(){
        rowNum = Integer.valueOf(apexpages.currentpage().getparameters().get('index'));
        class_enrollmentsList.remove(rowNum);   
    }
}

1) Can anyone offer me tips on how to modify that code to successfully pass the parent record ID to the child records? 

2) If you add a second row and decide to remove it, the "X" to delete the row is not working.

Thank you!

Blair
  • November 11, 2019
  • Like
  • 0
Would really appreciate help correcting my code to get this working!

I am attempting to create a Visualforce page where users can add multiple child records at once. I want to add a list button to the related list on the parent object. Both are custom objects.

The parent object in this scenario Sessions__c and the child object is Class_Enrollments__c. Not sure if this is applicable, but Groups_and_Classes__c is the parent of Sessions__c.

I am new to development, so I reworked some code based on code I found online. Basically, I want users to be able to click a "Add Class Enrollments" button on the Class Enrollments list on the Session record. I want this to take them to a Visualforce page where they can add as many rows as needed, populating the Youth Name, Attendance, and Participation Note fields.

I originally built this with a custom controller, and the visualforce page looked great, except the delete row function was not actually deleting the row. However, when trying to add the button to the page, I realized I have to use a Standard Controller. I've spent hours researching this at this point and have been unable to successfully add the standard controller to the visualforce page and use the controller I created as an extension. I've modified my controller to reference the standardsetcontroller, but then I get a "compile error=unknown token: Id". Basically, I'm so new to this that I'm in over my head. Could anyone please help me correct my code? I would greatly appreciate it.

VF (not edited to reflect ways I tried to add standard controller):
<apex:page controller="AddingEnrollmentsController">
    <apex:form>
        <apex:variable var="rowNum" value="{!0}"  />
        <apex:pageBlock >
            <apex:variable var="rowNum" value="{!0}"  />  
            <apex:pageBlockTable value="{!Class_EnrollmentsList}" var="CE">
                <apex:facet name="footer">
                    <apex:commandLink value="Add" action="{!insertRow}"/>
                </apex:facet>
                <apex:column headerValue="Youth Name">
                    <apex:inputField value="{!CE.Youth_Name__c}"/>
                </apex:column>
                <apex:column headerValue="Attended?">
                    <apex:inputField value="{!CE.Attended_Class__c}"/>
                </apex:column>
                 <apex:column headerValue="Participation Level">
                    <apex:inputField value="{!CE.Participation_Level__c}"/>
                </apex:column> 
                <apex:column headerValue="Comments">
                 <apex:inputField value="{!CE.Comments_for_Treatment_Team__c}"/>
                 </apex:column>            
                <apex:column headerValue="Delete" >
                    <apex:commandLink style="font-size:15px; font-weight:bold; text-align:center;color:red;" value="X" action="{!delRow}">
                        <apex:param value="{!rowNum}" name="index" />
                    </apex:commandLink>
                    <apex:variable var="rowNum" value="{!rowNum+1}"/>
                </apex:column>          
            </apex:pageBlockTable>
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!insertClass_Enrollments}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller (again not updated to reflect my attempts to add the standardsetcontroller):

public class AddingEnrollmentsController {
    Id SessionId;
    public List<Class_Enrollments__c> class_enrollmentsList {get;set;}
    public Integer rowNum{get;set;}
    
    public AddingEnrollmentsController(){
       Id class_enrollmentsId = ApexPages.currentPage().getParameters().get('class_enrollmentsId');
       SessionId=ApexPages.currentPage().getParameters().get('SessionId');
       class_enrollmentsList = new List<Class_Enrollments__c>();  
       class_enrollmentsList.add(new Class_Enrollments__c());      
    }
    
    public pagereference insertClass_Enrollments(){
    insert class_enrollmentsList;
    Pagereference page=new pagereference('/'+SessionId);
    Return page;
}
    
    public void insertRow(){
        class_enrollmentsList.add(new Class_Enrollments__c()); 
    }

    public void delRow(){
        rowNum = Integer.valueOf(apexpages.currentpage().getparameters().get('index'));
        class_enrollmentsList.remove(rowNum);   
    }
}

Any help is greatly appreciated!!!!
 
  • November 06, 2019
  • Like
  • 0
Hi all,

I am attempting to create a Visualforce page where users can add multiple child records at once. I want to add a list button to the related list on the parent object. Both are custom objects.

The parent object in this scenario Sessions__c and the child object is Class_Enrollments__c. Not sure if this is applicable, but Sessions__c is the child of Groups_and_Classes__c.

I am new to development, so I reworked some code based on code I found online. Basically, I want users to be able to click a "Add Class Enrollments" button on the Class Enrollments list. I want this to take them to a Visualforce page where they can add as many rows as needed, populating the Youth Name, Attendance, and Participation Note fields.

The code worked when I used the custom controller. However, when I tried to add the list button, I realized that it was not available in Content because I used a custom controller. I tried to amend the code for the Standard Controller, but I keep getting errors. Here is my original code:

<apex:page controller="AddingEnrollmentsController">
    <apex:form >
        <apex:variable var="rowNum" value="{!0}"  />
        <apex:pageBlock >
            <apex:variable var="rowNum" value="{!0}"  />  
            <apex:pageBlockTable value="{!Class_EnrollmentsList}" var="CE">
                <apex:facet name="footer">
                    <apex:commandLink value="Add" action="{!insertRow}"/>
                </apex:facet>
                <apex:column headerValue="Youth Name">
                    <apex:inputField value="{!CE.Youth_Name__c}"/>
                </apex:column>
                <apex:column headerValue="Attendance">
                    <apex:inputField value="{!CE.Attendedance__c}"/>
                </apex:column>
                 <apex:column headerValue="Participation Notel">
                    <apex:inputField value="{!CE.Participation_Note__c}"/>                        <apex:column headerValue="Delete" >
                    <apex:commandLink style="font-size:15px; font-weight:bold; text-align:center;color:red;" value="X" action="{!delRow}">
                        <apex:param value="{!rowNum}" name="index" />
                    </apex:commandLink>
                    <apex:variable var="rowNum" value="{!rowNum+1}"/>
                </apex:column>          
            </apex:pageBlockTable>
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!insertClass_Enrollments}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

public class AddingEnrollmentsController {
    Id SessionId;
    public List<Class_Enrollments__c> Class_EnrollmentsList {get;set;}
    public Integer rowNum{get;set;}
    
    public AddingEnrollmentsController(){
        SessionId = ApexPages.currentPage().getParameters().get('SessionId');
        Class_EnrollmentsList = new List<Class_Enrollments__c>();  
        Class_EnrollmentsList.add(new Class_Enrollments__c());      
    }
    
    public void insertClass_Enrollments(){
        insert Class_EnrollmentsList;
    }
    
    public void insertRow(){
        Class_EnrollmentsList.add(new Class_Enrollments__c()); 
    }
    
    public void delRow(){
        rowNum = Integer.valueOf(apexpages.currentpage().getparameters().get('index'));
        Class_EnrollmentsList.remove(rowNum);   
    }
}

When previewing this, it looks great, except the delete doesn't work. 

When I try to update it to the Standard Controller, however, I get this error:

Error: Unknown property 'Class_Enrollments__cStandardController.classenrollmentsList'

I have tried formatting that list element every way I can imagine (Class_EnrollmentsList, Class_Enrollments__cList, Class_Enrollments__c_List, etc.), and it still won't work. 

Here is the updated code:

<apex:page standardController="Class_Enrollments__c" recordSetVar="classenrollments">
    <apex:form >
        <apex:variable var="rowNum" value="{!0}"  />
        <apex:pageBlock >
            <apex:variable var="rowNum" value="{!0}"  />  
            <apex:pageBlockTable value="{!classenrollmentsList}" var="CE">
                <apex:facet name="footer">
                    <apex:commandLink value="Add" action="{!insertRow}"/>
                </apex:facet>
                <apex:column headerValue="Youth Name">
                    <apex:inputField value="{!CE.Youth_Name__c}"/>
                </apex:column>
                <apex:column headerValue="Attendance">
                    <apex:inputField value="{!CE.Attendedance__c}"/>
                </apex:column>
                 <apex:column headerValue="Participation Notel">
                    <apex:inputField value="{!CE.Participation_Note__c}"/> 
                <apex:column headerValue="Delete" >
                    <apex:commandLink style="font-size:15px; font-weight:bold; text-align:center;color:red;" value="X" action="{!delRow}">
                        <apex:param value="{!rowNum}" name="index" />
                    </apex:commandLink>
                    <apex:variable var="rowNum" value="{!rowNum+1}"/>
                </apex:column>          
            </apex:pageBlockTable>
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!insertclassenrollments}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Help?? I'm so new to this that I'm not sure what I am doing wrong. Any help is appreciated!
  • November 03, 2019
  • Like
  • 0

Hello,

I am hoping to get a trigger that will update a custom object checkbox and date field when a task is marked as complete.

The task is generated by a detail object and I want the master object to be updated when the task is complete.

Basically, there is an object called Position Posting which is the master object. The detail object, Job Application, is triggering the task. I would love for the trigger to update the master record, Position Posting, when the task is marked as complete. If that doesn't work, I could make it work for it to update the detail object, Job Application, instead.

Could anyone help with a trigger? I am totally new to coding so if someone could bold the areas where I need to plug in our own object/field names, that would be helpful.

Thank you for your help!!!

Hello all,

I am hoping to create a workflow rule that will assign tasks for various things. When these tasks are marked as complete, I'd like to trigger an update to a custom object that checks a checkbox to show it's been completed as well as update the date. I understand this cross object update is not possible with workflow.

Could this be possible with either process builder/flows/triggers or some combination? I am a point and click administrator at this point so I don't have any coding knowledge. Any help would be appreciated!

Thank you,

Blair
Hello,

I am hoping for some help with a way to update the names of several child records if the name of a Contact is changed.

Here's a recent example of why I think this would be helpful:

We are a social services agency who works with clients. Each client has a contact record and each contact record has several child records, such as Medical Information, Case Management, Education, etc. 

Because these child records are parent records as well, they are named with the name of the contact for easier searching/organization.

Occasionally, we may find out we were given inaccurate information about someone or misspelled someone's name, thus necessitating updating the contact's first name field, last name field, or both.

This also necessitates us editing all child records that are named according to that client's name. 

I know I cannot update via workflow a child record based on a change in the parent.

However, I have heard triggers can accomplish this-would anyone be willing to help a nonprofit out and help me with this?

Thank you!
  • September 05, 2014
  • Like
  • 0
I wanted to reach out and see if the following two projects we'd like help with are feasible and if so, what it might cost us.

First-we would love a custom clone button that clones the existing record along with the related records on the record's related list. The record is basically kind of a middle child in the hierarchy-it has a parent but it also has child records associated with it. When we clone it, we'd like to clone the record and its child records. 

Second-we'd love to automate some record creation based on when a new Contact record is created. What records would be created would be dependent on contact record type. Whenever we have certain contacts created, we will always need certain child records. Right now I am manually creating them (they're just basic records that house other related child records like "Medical Information" which has related lists for Medications, Appointments, etc.), but I'd like to not have to remember to do this for every new contact created. 

I am happy to give more detail about what we're specifically looking for, but wanted to first throw this out there and see if anyone was interested in helping out. We are a non-profit agency so our budget is small. We may not be able to make it work financially but wanted to see what it may cost. We do not have a developer on staff-I have learned a lot and am pretty handy with Salesforce but don't know Apex, etc. So you'd be working with someone who has strong administrative knowledge, just no coding experience.

Thanks,

Blair

I work at a nonprofit social services agency. One big part of our agency is case management. One of the things we do on a monthly basis are case management monthly summaries. Along with those summaries every month, the client has goals. These goals are updated from month to month and new ones are added. Right now we have a series of relationships.

 

Individuals (Contacts) are the master relationship. Case Management is an object that is the detail in a master-detail relationship with Contacts. Under case management, Monthly Case Management Summary is the detail relationship in a master-detail with Case Management. And then goal records are the detail in a master detail relationship with Monthly Case Management Summary.

 

Basically like this:

 

Contacts

|

Case Management

|

Monthly Case Management

Goal Records

 

Every month, the summary is very similar. We keep a lot of information on there and add updates or any changes. We also update any goal records or add new ones. So, monthly it is likely we will make use of the "Clone" button so we don't have to reinvent the wheel with every monthly update. 

 

The problem however is that the goal records don't copy over. We could take away the relationship with the monthly case management summary and just make them related to Case Management, but we like the idea of them being together. Cloning each individual goal record (when at times the client could have 10-15 or even more) would be tedious and inefficient.

 

I posed this question in the forum and it was suggested that a developer could write code that would create a "Copy" button that would copy the monthly summary AND the related goal records over. We don't have anyone on staff that has that kind of coding knowledge.

 

I am writing to the forum to see if there's a developer that may be able to help us out with this. If you are interested, please contact me and let me know what fee you would charge.


Thank you.

  • August 22, 2013
  • Like
  • 0

Hello,

 

I am hoping I can get a more experienced programmer/coder's help on an issue I'm having.

 

I am relatively new to the Salesforce platform but have been tasked with getting a functional database up and running for the social services agency where I work. We offer residential services for our clients and we have a great deal of data we want to track about each client and about each program and that program's residences. We have many many custom objects and many many relationships between objects.

 

One of the most basic things we do every week is a roster of each program and its residences and some information about each client currently in each program/residence. After a lot of time/work I figured out a way to get a current roster for each residence and each program (this is tricky as clients can move across programs or to a different residence within the same program). One of the items we report on weekly in that roster is the client's current level of skills and privileges. This level is set weekly at case management meetings. The way the database is set up currently, we have our clients as Contacts and the Contact is the master in the master-detail relationship with many other objects. Another object that we have is "Case Management" which is the detail in the master-detail relationship with Contact. Within Case Management, there is an object for the weekly Team Meetings. This object is the detail in a master-detail relationship with Case Management. So it's related to Contact, but not directly. 

 

We do our reporting on the roster every week from the Enrollment object which is a junction object between Contact and Program. I want to be able to include the most recent skills and privileges level on the roster (from the Team Meetings object) but I cannot figure out how to get that onto the report.


What would be nice is to always have a field that updates with the most recent skills/privileges level on either the Case Management object or the Contact's main detail page. I can't sort out how to do this. Every week a new record is created (in Team Meetings) with information from that week's meeting. I don't know how to get a field to update with the most recent skills/privileges level. This field is a picklist (as there are a standard set of levels), so roll-up summary doesn't work. So, my first issue is how to somehow parse out from the many records a client will have what the most recent level is and then how to reflect that into a report.


This seems like it may require some programming/coding knowledge that I do not have, so I am really hoping someone in this forum can help me out! I know this is a long explanation. Please let me know if there's anything I can clarify. 

I wanted to reach out and see if the following two projects we'd like help with are feasible and if so, what it might cost us.

First-we would love a custom clone button that clones the existing record along with the related records on the record's related list. The record is basically kind of a middle child in the hierarchy-it has a parent but it also has child records associated with it. When we clone it, we'd like to clone the record and its child records. 

Second-we'd love to automate some record creation based on when a new Contact record is created. What records would be created would be dependent on contact record type. Whenever we have certain contacts created, we will always need certain child records. Right now I am manually creating them (they're just basic records that house other related child records like "Medical Information" which has related lists for Medications, Appointments, etc.), but I'd like to not have to remember to do this for every new contact created. 

I am happy to give more detail about what we're specifically looking for, but wanted to first throw this out there and see if anyone was interested in helping out. We are a non-profit agency so our budget is small. We may not be able to make it work financially but wanted to see what it may cost. We do not have a developer on staff-I have learned a lot and am pretty handy with Salesforce but don't know Apex, etc. So you'd be working with someone who has strong administrative knowledge, just no coding experience.

Thanks,

Blair
Hello,

I have a custom object (Warehouse Visit) that is the child record of Contact. I'd like to click a button on the Warehouse Visit tab where multiple records can be created on one Visualforce page. Basically, I'd like staff to be able to log multiple visits on one page rather than add them one by phone.

On the VF page, I'd like a link that says "add" to allow staff to add multiple rows for each record (3-4 fields). At the end of each row, I want a Remove or X link to remove that row if it was created in error. Then, on save, I'd like it to redirect back to the Warehouse Visit tab. 

I haven't started building the VF page yet, but I'd like to enter about 4 fields, including a lookup to the Contact, a couple of date/time fields, and maybe a checkbox or picklist. 

I have started with this Apex class code, based on a previous button I had help developing, but I'm getting an error. Can anyone help fix this code?

public class WarehouseVisitController {
    public List<Warehouse_Visit__c> wvRecord{get; set;}
    public Integer wvIndex {get; set;}

    public WarehouseVisitController  (){
        wvRecord = new List<Warehouse_Visit__c>();
        wvRecord.add(new Warehouse_Visit__c);
    } #this is where the error is happening
    public void addWarehouseVisit () {
        wvRecord.add(new Warehouse_Visit__c);
    }
    public void removeWarehouseVisit() {
        wvIndex = Integer.valueOf(ApexPages.currentPage().getParameters().get('wvIndex'));
        wvRecord.remove(wvIndex);
    }
    public PageReference save() {
        upsert wvRecord;
        PageReference page = new PageReference('/');
        return page;
    }
    public PageReference cancel() {
        PageReference page = new PageReference('/' );
        return page;
    }
}

 

Hello all,

I've been trying for awhile to create a list button that will allow the creation of multiple child records of the same parent record on one Visualforce page (rather than clicking save and new over and over). I need to pass the parent ID and assign a record type, and I'd prefer that happen without the user having to do anything other than click the button on the related list. My visualforce page works in that if I preview it, I can see each field in a column, and the "add" link is working to add new rows. However, the parent ID isn't getting passed, I can't figure out how to assign the record type ID, and the "x" link to delete a row isn't working.

I've posted on the forum about this multiple times, but have not received many replies.

This would be a huge help for the organizations I work with, and I'd be willing to pay for a few hours of someone's time to help me get the code right. Any one interested in helping me out?

  • February 04, 2020
  • Like
  • 0
Hi,

I am attempting to create a visualforce page that will be accessed from a button on a related list. This button will allow users to add multiple child records related to the parent record. 

The parent object is Sessions__c and the child object is Class_Enrollments__c. I want users to be able to click the button and be routed to a VF page where they can add child records on one page.

I am running into three issues:

1) Whenever I try to save the record, I get the following error:

System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Session]: [Session]
Error is in expression '{!insertClass_Enrollments}' in component <apex:commandButton> in page add_class_enrollments: Class.AddingEnrollmentsController.insertClass_Enrollments: line 14, column 1
Class.AddingEnrollmentsController.insertClass_Enrollments: line 14, column 1

So, the parent record ID is not being passed to the child records.

2) I want to assign the record type ID to new child records. Child records will have the same record type for this particular page/button.

3) The "Delete" row function is not working

Below is my controller extension:

User-added image
VF page:

User-added image
Finally, all of this is being accessed via a list button that has the following URL:

/apex/Add_Class_Enrollments?SessionId={!Class_Enrollments__c.SessionId__c}

Help appreciated!

 
  • November 18, 2019
  • Like
  • 0
Hello,

I have created a Visualforce page where users can add multiple child records at once. I want to add a list button to the related list on the parent object. Both are custom objects.The parent object in this scenario Sessions__c and the child object is Class_Enrollments__c. 

Despite trying to use a Standard Controller + Extension, the VF page is not appearing in the Content when trying to add a custom list button. So, instead, I am passing it through the URL (/apex/Add_Class_Enrollments?class_enrollmentsId={!Class_Enrollments__c.Id}).

The below code is not working to pass the Session ID to the Class Enrollment records. The button opens the VF page and the VF page looks correct. However, when I try to save, it gives this error: System.DmlException: Insert failed. First exception on row 0; first error: REQUIRED_FIELD_MISSING, Required fields are missing: [Session]: [Session]
Error is in expression '{!insertClass_Enrollments}' in component <apex:commandButton> in page add_class_enrollments: Class.AddingEnrollmentsController.insertClass_Enrollments: line 14, column 1

Here is my VF code:

<apex:page standardController="Class_Enrollments__c" recordSetVar="enrollments" extensions="AddingEnrollmentsController">
    <apex:form >
        <apex:variable var="rowNum" value="{!0}"  />
        <apex:pageBlock >
            <apex:variable var="rowNum" value="{!0}"  />  
            <apex:pageBlockTable value="{!Class_EnrollmentsList}" var="CE">
                <apex:facet name="footer">
                    <apex:commandLink value="Add" action="{!insertRow}"/>
                </apex:facet>
                <apex:column headerValue="Youth Name">
                    <apex:inputField value="{!CE.Youth_Name__c}"/>
                </apex:column>
                <apex:column headerValue="Works Wonders Record">
                    <apex:inputField value="{!CE.Works_Wonders_Youth_Name__c}"/>
                </apex:column>
                <apex:column headerValue="Attendance">
                    <apex:inputField value="{!CE.Attendance__c}"/>
                </apex:column>
                 <apex:column headerValue="Participation Note">
                    <apex:inputField value="{!CE.Participation_Note__c}"/>
                </apex:column>         
                <apex:column headerValue="Delete" >
                    <apex:commandLink style="font-size:15px; font-weight:bold; text-align:center;color:red;" value="X" action="{!delRow}">
                        <apex:param value="{!rowNum}" name="index" />
                    </apex:commandLink>
                    <apex:variable var="rowNum" value="{!rowNum+1}"/>
                </apex:column>          
            </apex:pageBlockTable>
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!insertClass_Enrollments}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller extension:

public class AddingEnrollmentsController {
    Id SessionId;
    public List<Class_Enrollments__c> class_enrollmentsList {get;set;}
    public Integer rowNum{get;set;}
    
    public AddingEnrollmentsController(ApexPages.StandardSetController controller){
       Id enrollmentsId = ApexPages.currentPage().getParameters().get('enrollmentsId');
       SessionId=ApexPages.currentPage().getParameters().get('SessionId');
       class_enrollmentsList = new List<Class_Enrollments__c>();  
       class_enrollmentsList.add(new Class_Enrollments__c());      
    }
    
    public pagereference insertClass_Enrollments(){
    insert class_enrollmentsList;
    Pagereference page=new pagereference('/'+SessionId);
    Return page;
}
    
    public void insertRow(){
        class_enrollmentsList.add(new Class_Enrollments__c()); 
    }

    public void delRow(){
        rowNum = Integer.valueOf(apexpages.currentpage().getparameters().get('index'));
        class_enrollmentsList.remove(rowNum);   
    }
}

1) Can anyone offer me tips on how to modify that code to successfully pass the parent record ID to the child records? 

2) If you add a second row and decide to remove it, the "X" to delete the row is not working.

Thank you!

Blair
  • November 11, 2019
  • Like
  • 0
Would really appreciate help correcting my code to get this working!

I am attempting to create a Visualforce page where users can add multiple child records at once. I want to add a list button to the related list on the parent object. Both are custom objects.

The parent object in this scenario Sessions__c and the child object is Class_Enrollments__c. Not sure if this is applicable, but Groups_and_Classes__c is the parent of Sessions__c.

I am new to development, so I reworked some code based on code I found online. Basically, I want users to be able to click a "Add Class Enrollments" button on the Class Enrollments list on the Session record. I want this to take them to a Visualforce page where they can add as many rows as needed, populating the Youth Name, Attendance, and Participation Note fields.

I originally built this with a custom controller, and the visualforce page looked great, except the delete row function was not actually deleting the row. However, when trying to add the button to the page, I realized I have to use a Standard Controller. I've spent hours researching this at this point and have been unable to successfully add the standard controller to the visualforce page and use the controller I created as an extension. I've modified my controller to reference the standardsetcontroller, but then I get a "compile error=unknown token: Id". Basically, I'm so new to this that I'm in over my head. Could anyone please help me correct my code? I would greatly appreciate it.

VF (not edited to reflect ways I tried to add standard controller):
<apex:page controller="AddingEnrollmentsController">
    <apex:form>
        <apex:variable var="rowNum" value="{!0}"  />
        <apex:pageBlock >
            <apex:variable var="rowNum" value="{!0}"  />  
            <apex:pageBlockTable value="{!Class_EnrollmentsList}" var="CE">
                <apex:facet name="footer">
                    <apex:commandLink value="Add" action="{!insertRow}"/>
                </apex:facet>
                <apex:column headerValue="Youth Name">
                    <apex:inputField value="{!CE.Youth_Name__c}"/>
                </apex:column>
                <apex:column headerValue="Attended?">
                    <apex:inputField value="{!CE.Attended_Class__c}"/>
                </apex:column>
                 <apex:column headerValue="Participation Level">
                    <apex:inputField value="{!CE.Participation_Level__c}"/>
                </apex:column> 
                <apex:column headerValue="Comments">
                 <apex:inputField value="{!CE.Comments_for_Treatment_Team__c}"/>
                 </apex:column>            
                <apex:column headerValue="Delete" >
                    <apex:commandLink style="font-size:15px; font-weight:bold; text-align:center;color:red;" value="X" action="{!delRow}">
                        <apex:param value="{!rowNum}" name="index" />
                    </apex:commandLink>
                    <apex:variable var="rowNum" value="{!rowNum+1}"/>
                </apex:column>          
            </apex:pageBlockTable>
            <apex:pageBlockButtons >
                <apex:commandButton value="Save" action="{!insertClass_Enrollments}"/>
            </apex:pageBlockButtons>
        </apex:pageBlock>
    </apex:form>
</apex:page>

Controller (again not updated to reflect my attempts to add the standardsetcontroller):

public class AddingEnrollmentsController {
    Id SessionId;
    public List<Class_Enrollments__c> class_enrollmentsList {get;set;}
    public Integer rowNum{get;set;}
    
    public AddingEnrollmentsController(){
       Id class_enrollmentsId = ApexPages.currentPage().getParameters().get('class_enrollmentsId');
       SessionId=ApexPages.currentPage().getParameters().get('SessionId');
       class_enrollmentsList = new List<Class_Enrollments__c>();  
       class_enrollmentsList.add(new Class_Enrollments__c());      
    }
    
    public pagereference insertClass_Enrollments(){
    insert class_enrollmentsList;
    Pagereference page=new pagereference('/'+SessionId);
    Return page;
}
    
    public void insertRow(){
        class_enrollmentsList.add(new Class_Enrollments__c()); 
    }

    public void delRow(){
        rowNum = Integer.valueOf(apexpages.currentpage().getparameters().get('index'));
        class_enrollmentsList.remove(rowNum);   
    }
}

Any help is greatly appreciated!!!!
 
  • November 06, 2019
  • Like
  • 0

Hello,

I am hoping to get a trigger that will update a custom object checkbox and date field when a task is marked as complete.

The task is generated by a detail object and I want the master object to be updated when the task is complete.

Basically, there is an object called Position Posting which is the master object. The detail object, Job Application, is triggering the task. I would love for the trigger to update the master record, Position Posting, when the task is marked as complete. If that doesn't work, I could make it work for it to update the detail object, Job Application, instead.

Could anyone help with a trigger? I am totally new to coding so if someone could bold the areas where I need to plug in our own object/field names, that would be helpful.

Thank you for your help!!!

Hello all,

I am hoping to create a workflow rule that will assign tasks for various things. When these tasks are marked as complete, I'd like to trigger an update to a custom object that checks a checkbox to show it's been completed as well as update the date. I understand this cross object update is not possible with workflow.

Could this be possible with either process builder/flows/triggers or some combination? I am a point and click administrator at this point so I don't have any coding knowledge. Any help would be appreciated!

Thank you,

Blair
I wanted to reach out and see if the following two projects we'd like help with are feasible and if so, what it might cost us.

First-we would love a custom clone button that clones the existing record along with the related records on the record's related list. The record is basically kind of a middle child in the hierarchy-it has a parent but it also has child records associated with it. When we clone it, we'd like to clone the record and its child records. 

Second-we'd love to automate some record creation based on when a new Contact record is created. What records would be created would be dependent on contact record type. Whenever we have certain contacts created, we will always need certain child records. Right now I am manually creating them (they're just basic records that house other related child records like "Medical Information" which has related lists for Medications, Appointments, etc.), but I'd like to not have to remember to do this for every new contact created. 

I am happy to give more detail about what we're specifically looking for, but wanted to first throw this out there and see if anyone was interested in helping out. We are a non-profit agency so our budget is small. We may not be able to make it work financially but wanted to see what it may cost. We do not have a developer on staff-I have learned a lot and am pretty handy with Salesforce but don't know Apex, etc. So you'd be working with someone who has strong administrative knowledge, just no coding experience.

Thanks,

Blair

Hello,

 

I am hoping I can get a more experienced programmer/coder's help on an issue I'm having.

 

I am relatively new to the Salesforce platform but have been tasked with getting a functional database up and running for the social services agency where I work. We offer residential services for our clients and we have a great deal of data we want to track about each client and about each program and that program's residences. We have many many custom objects and many many relationships between objects.

 

One of the most basic things we do every week is a roster of each program and its residences and some information about each client currently in each program/residence. After a lot of time/work I figured out a way to get a current roster for each residence and each program (this is tricky as clients can move across programs or to a different residence within the same program). One of the items we report on weekly in that roster is the client's current level of skills and privileges. This level is set weekly at case management meetings. The way the database is set up currently, we have our clients as Contacts and the Contact is the master in the master-detail relationship with many other objects. Another object that we have is "Case Management" which is the detail in the master-detail relationship with Contact. Within Case Management, there is an object for the weekly Team Meetings. This object is the detail in a master-detail relationship with Case Management. So it's related to Contact, but not directly. 

 

We do our reporting on the roster every week from the Enrollment object which is a junction object between Contact and Program. I want to be able to include the most recent skills and privileges level on the roster (from the Team Meetings object) but I cannot figure out how to get that onto the report.


What would be nice is to always have a field that updates with the most recent skills/privileges level on either the Case Management object or the Contact's main detail page. I can't sort out how to do this. Every week a new record is created (in Team Meetings) with information from that week's meeting. I don't know how to get a field to update with the most recent skills/privileges level. This field is a picklist (as there are a standard set of levels), so roll-up summary doesn't work. So, my first issue is how to somehow parse out from the many records a client will have what the most recent level is and then how to reflect that into a report.


This seems like it may require some programming/coding knowledge that I do not have, so I am really hoping someone in this forum can help me out! I know this is a long explanation. Please let me know if there's anything I can clarify.