function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Ali Husain 3Ali Husain 3 

Get the id from the URL

Most of my scenario is complete but am having difficulities with a few areas (bottom of post).

I have a custom object Deal_Reg__c. The business flow for this object is that a user can go to this object's page and add a Product to this Deal Reg (related list of DealRegistrationProducts). I have created a junction object called Deal_Reg_Products__c that has a Deg Reg Lookup as well as a Product Lookup along with other custom fields. After you press the "Add" button on the Deal Reg Products Related List section of the Deal Reg page, i would like the first VF page to be displayed.

The first VF page should basically only be a selectable list of all the Products with the name of the Deal_Reg__c that we were coming from. After the user selects one or multiple records to add to the specific Deal Reg, they will press a button called "Add Product". Pressing that button should fire off the second VF page.

The second VF page should consist of the selected list of Products from the first VF page along with a Deal_Reg_Products__c.Forecast_Amount__c custom field, "Forecast Amount", next to each record where the user can input the value. After a value has been entered for each Product, the user will press a "Confirm" button which will send us back to the Deal Reg page where in the Deal Reg Products Related List section the selected Products are now visible with the Forecast Amount we entered and are now tied to that Deal Reg.

1. I would like to have a cancel button on both the visualforce pages. How can i get back to the original deal_reg__c?
public id dealregId;

public pageReference cancel(){
        return new PageReference('/'+dealregId);
    }
I though that this would work, but i get directed to a page with the error: URL No Longer Exists
The URL has now changed to: https://cs10.salesforce.com/null
 
siddarth rajsiddarth raj
You could try this to go to list view page on cancel()

Schema.DescribeSObjectResult result = Deal_Reg__c..SObjectType.getDescribe();
        PageReference pageRef = new PageReference('/' + result.getKeyPrefix() + '/o');
        pageRef.setRedirect(true);
        return pageRef;     
Ali Husain 3Ali Husain 3
Do you know why my code thinks dealregId = null?

Thanks,