Please see the following solution which is tested and working, please mark it as a solution if it is working out for you.
Apex Class:
public class VfContrl {
List<Id> recordIds;
public List<Account> accounts {get;set;}
public VfContrl() {
recordIds = new List<Id>();
recordIds.addAll((List<Id>)Apexpages.currentPage().getParameters().values());
//Assuming the object as Account
accounts = new List<Account>();
accounts = [Select Name, Industry from Account where id in: recordIds];
}
public void save() {
upsert accounts;
}
}
Your URL should be in the following format - https://c.ap2.visual.force.com/apex/AccountsFrmIdsOfUrl?id1=recordid&id2=recordid ----------- Thanks, Srinivas - Please mark as solution if your problem is resolved.
You need a combination of Apex class and VF page to acheive this
Following is a sample Apex class and VF page which works on Account object
Apex:
public class TestClass2 {
public string str{get;set;}
public Account ac{get;set;}
public TestClass2(){
Id acId = ApexPages.currentPage().getParameters().get('id');
if(acId!=null){
try{
// you can retrieve variables depending on your requirement
ac = [Select id,Name,Phone,Website From Account Where id=:acId Limit 1];
}catch(Exception e){
str = e.getMessage();
}
}
else
str = 'Invalid/Null Id';
}
public void updateAccount(){
if(ac.id!=null)
update ac;
}
}
VF:
<apex:page controller="TestClass2" >
<apex:form >
<!-- following section will show up only if url is invalid or there is some error in SOQL query -->
<apex:pageBlock rendered="{!str!=null}">
<h2 style="color:red">{!str}</h2>
</apex:pageBlock>
<!-- following section will show up only if a record is successfully retreived from database -->
<apex:pageBlock rendered="{!ac.id!=null}">
<apex:dataTable value="{!ac}" var="a">
<apex:column headerValue="Name">
<apex:inputtext value="{!a.Name}"/>
</apex:column>
<apex:column headerValue="Phone">
<apex:inputtext value="{!a.Phone}"/>
</apex:column>
<apex:column headerValue="Website">
<apex:inputtext value="{!a.Website}"/>
</apex:column>
<apex:column headerValue="Update">
<apex:commandButton action="{!updateAccount}" value="Update"/>
</apex:column>
</apex:dataTable>
</apex:pageBlock>
</apex:form>
</apex:page>
The URL should end with -> "?id=<Id of the record which has to be edited>" Use it as a template to meet your requirements.
mark this as Best Answer, if it solves your problem.
Please see the following solution which is tested and working, please mark it as a solution if it is working out for you.
Apex Class:
------
Visualforce Page:
-----------
Thanks,
Srinivas
- Please mark as solution if your problem is resolved.
https://c.ap2.visual.force.com/apex/AccountsFrmIdsOfUrl?id1=recordid&id2=recordid
-----------
Thanks,
Srinivas
- Please mark as solution if your problem is resolved.
Following is a sample Apex class and VF page which works on Account object
Apex:
VF:
The URL should end with -> "?id=<Id of the record which has to be edited>"
Use it as a template to meet your requirements.
mark this as Best Answer, if it solves your problem.