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
tdeptdep 

URL Variable Disappearing

Hey devforce,

 

Hope you enjoyed cloudforce 2011 if you attended (I know I did) :)

 

I am having an issue with a VF page I have created. I use a ?q={ID} for a query at the end of the URL to pull the project data for display. Below the user can add "Prospects" as related records to the main project.

 

It works when the page initially loads and writes it to the correct record but then after the first submission the URL changes to not have the ?q= string attached.

 

I'm not sure how to post the url back up or keep the variable stored without updating it again.

 

Thanks in advance,

 

Controller:

 

 

public with sharing class USPS_Prospects 
{

public USPS_Prospects__c newProspect { get; set; }
public USPS_Project__c newProject { get; set; }
public USPS_Project__c proj { get; set; }

public string uniqueID = System.currentPagereference().getParameters().get('q');

public string getUniqueID()
{
return uniqueID;
}


public list<USPS_Prospects__c> getUSPSProspects()
{
return [SELECT Id, Name, USPS_Project__c, Status__c, Comments__c, CreatedInfo__c
FROM USPS_Prospects__c
WHERE USPS_Project__c = :uniqueID ];
}

public USPS_Prospects() {
newProspect = new USPS_Prospects__c(USPS_Project__c = uniqueID);
}

public PageReference add() {
insert newProspect;
return null;
}
public PageReference getTest() {

proj = [ SELECT Id, Name, Street__c, State__c, Country__c, City__c, Square_Feet__c, Expiration_Date__c, Facility_Type__c
FROM USPS_Project__c
WHERE Id = :uniqueID ];
return null;
}


public list<USPS_Project__c> getUSPSProjects()
{
return [SELECT Id, Name, Street__c, State__c, Country__c, City__c, Square_Feet__c, Expiration_Date__c, Facility_Type__c
FROM USPS_Project__c
WHERE Id = :uniqueID ];
}

/*-------------------*/
/* Test Method */
/*-------------------*/

public static testMethod void USPS_Prospects()
{

USPS_Prospects controller = new USPS_Prospects();

USPS_Prospects__c testProspect = new USPS_Prospects__c
(
Name = 'Test',
Comments__c = 'Comments Information Placeholder',
Status__c = 'Tour'
);

controller.add();
controller.getUSPSProspects();

USPS_Project__c testProject = new USPS_Project__c
(
Name = 'TestProj',
Street__c = 'Street',
State__c = 'State',
Country__c = 'Country',
City__c = 'City',
Square_Feet__c = 1000,
Facility_Type__c = 'Office'
);

insert testProject;
controller.getUSPSProjects();

string uniqueID;
uniqueID = 'test123';
controller.getUniqueID();
}


}

 Page:

 

 

 

<apex:page controller="USPS_Prospects" sidebar="false" showHeader="false" cache="false" expires="900" title="USPS - Disposition Prospects"   >

<apex:image url="https://c.na3.content.force.com/servlet/servlet.ImageServer?id=01550000000qyIQ&oid=00D300000000XQU&lastMod=1297701458000" />

<input name="key" value="{!uniqueID}"/>

<apex:dataTable value="{!USPSProjects}" var="projectlist" cellpadding="2" border="1">

<apex:column headerValue="Project Information" width="250">
<table>
<tr> <td align="right"> <strong> Address: </strong> </td>
<td> <apex:outputText value="{!projectlist.Street__c}" /> </td> </tr>
<tr> <td align="right"> <strong> City: </strong> </td>
<td> <apex:outputText value="{!projectlist.City__c}" /> </td> </tr>
<tr> <td align="right"> <strong> State: </strong> </td>
<td> <apex:outputText value="{!projectlist.State__c}" /> </td> </tr>
<tr> <td align="right"> <strong> Country: </strong> </td>
<td> <apex:outputText value="{!projectlist.Country__c}" /> </td> </tr>
<br />
<tr> <td align="right"> <strong> Facility Type: </strong> </td>
<td> <apex:outputText value="{!projectlist.Facility_Type__c}" /> </td> </tr>
<tr> <td align="right"> <strong> Size (SF): </strong> </td>
<td> <apex:outputText value="{!projectlist.Square_Feet__c}" /> </td> </tr>
<tr> <td align="right"> <strong> Expiration: </strong> </td>
<td> <apex:outputText value="{!projectlist.Expiration_Date__c}" /> </td> </tr>
</table>

</apex:column>

</apex:dataTable>


<apex:pageBlock title="Add New Prospect">
<apex:form >
<table>
<tr> <td> Name: </td> <td> <apex:inputText value="{!newProspect.Name}" /> </td> </tr>
<tr> <td> Status: </td> <td> <apex:inputField value="{!newProspect.Status__c}" /> </td> </tr>
<tr> <td> Comments: </td> <td> <apex:inputText value="{!newProspect.Comments__c}" size="100" /> </td> </tr>
</table> <apex:commandButton value="Add" action="{!add}" />
</apex:form>
</apex:pageBlock>


<apex:pageBlock title="Previous Submissions">
<apex:form >
<apex:dataTable value="{!USPSProspects}" var="prospectlist" cellpadding="2" border="1">

<apex:column headerValue="Name" width="100">
{!prospectlist.name}
</apex:column>

<apex:column headerValue="Status" width="100">
{!prospectlist.Status__c}
</apex:column>

<apex:column headerValue="Comments" width="300">
{!prospectlist.Comments__c}
</apex:column>

<apex:column headerValue="Created Date" width="50">
{!prospectlist.CreatedInfo__c}
</apex:column>

<apex:column headerValue="Test ProjectID" width="50">
{!prospectlist.USPS_Project__c}
</apex:column>

</apex:dataTable>

</apex:form>
</apex:pageBlock>

</apex:page>

 

 

 

tdeptdep

Is there is a way to assign the q= URL variable and make it not change?

 

Any help would be greatly appreciated, thanks in advance :)