0

I'm getting an error message when I try to save records. The error message is:

     URL No Longer Exists
You have attempted to reach a URL that no longer exists on salesforce.com. 

You may have reached this page after clicking on a direct link into the application. This direct link might be: 
• A bookmark to a particular page, such as a report or view 
• A link to a particular page in the Custom Links section of your Home Tab, or a Custom Link 
• A link to a particular page in your email templates 

If you reached this page through a bookmark, you are probably trying to access something that has moved. Please update your bookmark. 

If you reached this page through any of the other direct links listed above, please notify your administrator to update the link. 

If you reached this page through a link on our site, please report the broken link directly to our Support Team and we will fix it promptly. Please indicate the page you were on when you clicked the link as well as any other related information. We apologize for the inconvenience. 

Thank you again for your patience and assistance. And thanks for using salesforce.com! 

The Visualforce page:

  <apex:page controller="sampleitem">
  <apex:form >
      <apex:pageblock >
          <apex:pageblocksection >
              <apex:pageblocktable value="{!lstWS}" var="S">
                  <apex:column headerValue="Select">
                      <apex:inputcheckbox value="{!S.ischecked}"/>
                  </apex:column>
                  <apex:column headerValue="Name">
                      <apex:outputtext value="{!S.swi.Name}"></apex:outputtext>
                  </apex:column>
                   <apex:column headerValue="Stage">
                      <apex:outputtext value="{!S.swi.Stage__r.Name}"></apex:outputtext>
                  </apex:column>
                  <apex:column headerValue="Item Name">
                      <apex:outputtext value="{!S.swi.Item__r.name}"></apex:outputtext>
                  </apex:column>
              </apex:pageblocktable>
          </apex:pageblocksection>
          <apex:commandButton value="Select" Action="{!doSave}"/>
      </apex:pageblock>
  </apex:form>

The class:

    public with sharing class sampleitem {

public PageReference doSave() {
    List<sample_Item__c> lstswi = new List<sample_Item__c>();
    List<Project_Task__c> lstpwi = new List<Project_Task__c>();
    for(wrapperSample objws : lstWS){
        if(objws.ischecked == true){
            Project_Task__c objP = new Project_Task__c();
            if(pid != null)
            objP.project__c = pid;
            objP.End_Date__c = system.today();
            objP.Start_Date__c = system.today();
            //objp.Predecessor_Task__c = objws.swi.Predecessor_Task__r.Id;
            if(objws.swi.predecessor_Task__r.Name != null)
            objP.Name = objws.swi.predecessor_Task__r.Name;
            objP.Owner__c = Userinfo.getUserId();
            if(objws.swi.project_stage__r.id != null)
            objP.Project_Stage__c = objws.swi.Project_Stage__r.id;
            if(objws.swi.Type__c != null)
            objP.Type__c = objws.swi.Type__c;
            objP.Task_Status__c = 'In Progress'; 
            lstpwi.add(objP);
        }
        }
    insert lstpwi; 
    return (new pagereference('/'+pid).setredirect(true));
}

public String pId = apexpages.currentpage().getparameters().get('pid');
public String wtId = apexpages.currentpage().getparameters().get('wid');
public List<sample_Item__c> lstSWI{get;set;}
public wrapperSample objWS{get;set;}
public List<wrapperSample> lstWS{get;set;}
public sampleitem(){
    lstSWI = new List<sample_Item__c>();
    lstSWI = new List<sample_Item__c>();
    lstSWI = [select id,name,Stage__r.Name,Item__r.name from sample_Item__c where Template__c =: wtId];
    lstWS = new List<wrapperSample>();
    for(sample_Item__c objSWI : lstSWI){
        objWS = new wrapperSample();
        objWS.swi = objSWI;
        lstWS.add(objWS);
    }
}
5
  • Check for Pid and looks like you are getting from URL above in sfdc? Nov 21, 2012 at 12:50
  • You are getting the error in the doSave method but you've provided the doSelect method in your code snippet. The answer is in the error message, you can't have populated a required field. Nov 21, 2012 at 12:58
  • it is a do save method
    – rakesh
    Nov 21, 2012 at 13:37
  • @rakesh - the error message says the problem is in doSave, but the class you provided us only shows a doSelect method. Please provide the doSave method.
    – Mike Chale
    Nov 21, 2012 at 13:45
  • @Mike now you can find doSave() method
    – rakesh
    Nov 21, 2012 at 13:48

2 Answers 2

0

I see that you've checked

if(pid != null)
          objP.project__c = pid;

This would potentially mean that if pid is null, objp.project__c has a null value.

This would cause an error when the records are inserted at

insert lstpwi; 

You probably want to assign a default value to cater for cases where pid comes out to be null. Are you passing a ?pid=value in the URL so that it is available as a query parameter to set on Project ?

9
  • pid=null in my url
    – rakesh
    Nov 21, 2012 at 13:59
  • this is the url i can see on top cs13.salesforce.com/apex/…
    – rakesh
    Nov 21, 2012 at 13:59
  • Is Project__c the Parent to a the master/detail relationship Project__c/Project_Task__c ? If so, you'd want the ID of the Project there rather than the word 'null', which looking at the URL you've provided above is exactly what you'd get. The query string parameter pId=null would give you the string value 'null' I think. Nov 21, 2012 at 14:18
  • @Phil Hawthorn project__c is master to project_task__c so do i need to replace the null with ID
    – rakesh
    Nov 21, 2012 at 14:23
  • @rakesh, yes it will definitely need to be a valid ID passed in the URL, I assum pId is the Project ID? Nov 21, 2012 at 14:28
1

It sounds like you're trying to save a record with an empty required field. Double-check which fields are required for the object and verify they are populated.

Update

Based on your comments below, your URL is Sampleitems?+pId=a0FW00000009RqX&WId=a0DW0000000I1bzMAC. Note that you have an extra plus sign (+) between the question mark and the paramenter pId.

14
  • At a guess I would say that the Project field needs a value in. Just playing a hunch though.
    – Doug B
    Nov 21, 2012 at 13:39
  • i didn't understand what is (trying to save a record with an empty required field)
    – rakesh
    Nov 21, 2012 at 13:40
  • project field had some value in it
    – rakesh
    Nov 21, 2012 at 13:42
  • In your doSave you have this if(pid != null) objP.project__c = pid; but what happens if pid = null?
    – Doug B
    Nov 21, 2012 at 13:49
  • @DougB can you help me out with this
    – rakesh
    Nov 21, 2012 at 13:54

Not the answer you're looking for? Browse other questions tagged .