Find your content:

Search form

You are here

Is there any issues in this code i am getting Visualforce Error


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 

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! 

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 headerValue="Name">
                      <apex:outputtext value="{!S.swi.Name}"></apex:outputtext>
                   <apex:column headerValue="Stage">
                      <apex:outputtext value="{!S.swi.Stage__r.Name}"></apex:outputtext>
                  <apex:column headerValue="Item Name">
                      <apex:outputtext value="{!}"></apex:outputtext>
          <apex:commandButton value="Select" Action="{!doSave}"/>

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 =;
            objP.Start_Date__c =;
            //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( != null)
            objP.Project_Stage__c =;
            if(objws.swi.Type__c != null)
            objP.Type__c = objws.swi.Type__c;
            objP.Task_Status__c = 'In Progress'; 
    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, from sample_Item__c where Template__c =: wtId];
    lstWS = new List<wrapperSample>();
    for(sample_Item__c objSWI : lstSWI){
        objWS = new wrapperSample();
        objWS.swi = objSWI;

Attribution to: rakesh

Possible Suggestion/Solution #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.


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.

Attribution to: Mike Chale

Possible Suggestion/Solution #2

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 ?

Attribution to: techtrekker
This content is remixed from stackoverflow or stackexchange. Please visit

My Block Status

My Block Content