You need to sign in to do that
Don't have an account?
Steve Cairney
Is it possible to create records within a VF page
Hi, I'm creating something that makes use of four custom objects.
The objects are related to the Opp object and are as follows
-Booking object
-Product (not SF native product, it's just names the same)
-Design
-Delivery
What I'm discovering is that to add a booking to the Opp with products, designs and deliveries is extremely unweildy for the user and requeries a great deal of clicks and I want to design the process to be as easy as possible.
Is it possible to create a visual force page all the fields neccessary for each object are visible? I fear this may require trigger writing, but if that's the case I'll post the question elswhere but I thought I'd ask here first.
The objects are related to the Opp object and are as follows
-Booking object
-Product (not SF native product, it's just names the same)
-Design
-Delivery
What I'm discovering is that to add a booking to the Opp with products, designs and deliveries is extremely unweildy for the user and requeries a great deal of clicks and I want to design the process to be as easy as possible.
Is it possible to create a visual force page all the fields neccessary for each object are visible? I fear this may require trigger writing, but if that's the case I'll post the question elswhere but I thought I'd ask here first.
Then create a custom button on the opportunity object. If you want the button to work on a particular stage, then select the behaviour as "Execute Javascript" and in the text area use the following code. Change the stage name to check accordingly.
Hope this helps.
All Answers
Yes, it is possible to create records from visualforce page. You can use the standard conroller or create an extend the standard controller with a custom class to fit the purpose. But your use case scenario is not clear. Can you provide more details on your custom objects and their relationships and the relationship with the opportunity object.
Provide more details, so I can help.
Regards,
Krishna.
Ok, so when an opportunity reaches a certain criteria the user must do the following
Create a new Booking. Each Booking as a specific date (In-charge date)
Within the Booking there can be multiple Products
Each Product can have multiple Designs
Each Design can have multple Deliveries and each delivery has a quantity.
Note, Opps can have multiple Bookings.
Currently the Opp looks like this (with related lists), but it was extremely time consuming to fill this out.
If I understand correctly, you want the visualforce page to display the fields related to each of those objects and the user fills all those fields at once and create the records for each of these objects in one click. Is that right?
Regards,
Krishna.
Then create a custom button on the opportunity object. If you want the button to work on a particular stage, then select the behaviour as "Execute Javascript" and in the text area use the following code. Change the stage name to check accordingly.
Hope this helps.
I'm interested to know what should follow the API name? In your example it's "booking" but is this the Object Name?
So using real terms it would be
public ItsApproved_Booking__c booking {get; set;}
For the opportunityId, there is a small correction. it should be private string opportunityId;
Hope this helps.
However, the next lines aren't to clear. Should they be the corresponding lookup fields for the object? Example
Is this looking for the lookup field from the first object (the ItsApprovedBooking) so it can relate that to the Product?
Sorry I'm asking so many questions but I'm unfortunately not technically a developer (but tht's life!)
What I'm seeing looks like an excelent start but for some reason I can't actually input text.
Booking_Title on the ItsApprovedBooking object is a text field yet it's not possible to input text. Will the class need updating with the fields?
<apex:inputField value="{!ItsApprovedBooking.Booking_Title__c}"/>
However, I'm hitting an error on Save.
First, here's the codes
Class
The VF page
However, as I said on Saving SF displays the following error which seems to point to insert ItsApprovedDelivery in the class...
The only required fields I can think of for product would be the lookup for the ItsApprovedBooking.Name however, how can we add those on creation?
So before "insert ItsApprovedDelivery;" statement add the following.
ItsApprovedDelivery.Product__c = ItsApprovedProduct.Id;
I hope the above field name is correct.
There are a couple of additional things I'd like to be able to do.
1. As I stated before, Although there is only 1 ItsApprovedBooking, that booking can have multiple products, multiple designs and multiple deliveries. Would there be a way to add addition products, designs and deliveries in the page?
2. Instead of using the related lists in the Opps, a visual force aspect would be much better. It could list the various
addProduct
addDesign
addDelivery
perhaps then I will be able to add an extension class to the main booking page and use a custom save action so if I needed to add more, it would redirect to the relevant addPage.
Does that sound like I'm onto the right track?
The easiest way is to use the buttons on the standard layout, if you want to add a new product to an existing booking and so on and use this page if you want to create a new booking and corresponding product. Here is a sample code for adding multiple products. In the visualforce page in the product section add the lookup for the Booking Reference. Here you can only pick the bookings already created, not the current one which you filled in the booking section, because this booking is not yet created. If you want the current booking to be available in the lookup, you need to save it first, by adding a new method in the controller to save the booking.
Hope you have an understanding of how it works.
https://developer.salesforce.com/forums/?id=906F0000000BQ0VIAW
I'm looking for code online and I'm afraid it's confusing. I can't work out if I need to add a new class and adding to the currently class only fails...
https://developer.salesforce.com/forums/ForumsMain?id=906F0000000MLpmIAG