+ Start a Discussion
srikanth Gottimukkalasrikanth Gottimukkala 

checkbox click

hi
i want to create a standard acount record page in a list of records using check box ,i have entered the checkbox and record names in a page so when i click the check box the respective record name is side to the check box like wise list of records names with check boxes are available in page when i enter submit button by clicking checkbox the respective record name page would want to display in standard.can any one explain the code
 
Best Answer chosen by srikanth Gottimukkala
Amit Chaudhary 8Amit Chaudhary 8
Hi Srikanth,

Below link will be help you. In below Link we are showing Contact recod with checkbox.

https://developer.salesforce.com/page/Wrapper_Class

Please replace "processSelected" function with below function.
public PageReference processSelected() 
	{
		List<Contact> selectedContacts = new List<Contact>();

		for(cContact cCon: getContacts()) 
		{
			if(cCon.selected == true) 
			{
				selectedContacts.add(cCon.con);
			}
		}
		String selectedRecordID = '' ;
		for(Contact con : selectedContacts) 
		{
			system.debug(con);
			selectedRecordID = con.id;
		}
		contactList=null; // we need this line if we performed a write operation  because getContacts gets a fresh list now
		
		return new PageReference('/'+selectedRecordID);
		//return null;
	}
Only on concurn i have with your design in list view you are showing checkbox. With Checkbox your can select multiple record at a time but above code will open only one record.
 
return new PageReference('/'+selectedRecordID);


Please let us know if this will help you.

Thanks,
Amit Chaudhary

All Answers

ManojjenaManojjena
Hi Srikanth ,
Your requirment is not clear enough to give some suggetion .Please elaborate bit more ,if possibel write steps what excatly you want .

Thanks
Manoj
srikanth Gottimukkalasrikanth Gottimukkala
hi
I have created records list with check boxs in a page and created a submit buttton.Now my requirement is when i select the checkbox and click on          the submit button i want to go to that standard record page.User-added image
  
ManojjenaManojjena
Hi Srikanth,
Still I have question ,
1.Which standard page you want to move ,record edit page or detail page ?
Approach 1-
If you want to open selected record detail page then ,I think you will eaisly get the id of the selected record and use below code to form the redirect URL .

String fullFileURL = URL.getSalesforceBaseUrl().toExternalForm();//It will give you the base URL means https://datacentername.salesforce .com
then you add   fullFileURL +/recId; it will work .
If you want to redirect to the edit mode follow same way only extra thing you need to add is
fullFileURL +'/'+recId+'/e';
2.If user will select more than one check box then ?
Please let me know if it helps .
 
Amit Chaudhary 8Amit Chaudhary 8
Hi Srikanth,

Below link will be help you. In below Link we are showing Contact recod with checkbox.

https://developer.salesforce.com/page/Wrapper_Class

Please replace "processSelected" function with below function.
public PageReference processSelected() 
	{
		List<Contact> selectedContacts = new List<Contact>();

		for(cContact cCon: getContacts()) 
		{
			if(cCon.selected == true) 
			{
				selectedContacts.add(cCon.con);
			}
		}
		String selectedRecordID = '' ;
		for(Contact con : selectedContacts) 
		{
			system.debug(con);
			selectedRecordID = con.id;
		}
		contactList=null; // we need this line if we performed a write operation  because getContacts gets a fresh list now
		
		return new PageReference('/'+selectedRecordID);
		//return null;
	}
Only on concurn i have with your design in list view you are showing checkbox. With Checkbox your can select multiple record at a time but above code will open only one record.
 
return new PageReference('/'+selectedRecordID);


Please let us know if this will help you.

Thanks,
Amit Chaudhary
This was selected as the best answer
srikanth Gottimukkalasrikanth Gottimukkala
Hi Amith,
         the above code you have given is working but when i select checkboxs of  multiple records in a page the last checkbox which i was selected was redirecting to that record page, can you explain only one checkbox  i want to select and remaing checkboxes in a page want to be unchecked .so that only selected checkbox would be redirected to that page.
 
ManojjenaManojjena
Hi Srikanth,

I think you should use radio button in place of check box it will help .
Amit Chaudhary 8Amit Chaudhary 8
Hi Srikanth Gottimukkala,

Please add some java script code to unchecked all other checkbox. Or add radio button.

Some usefull link for you.
https://developer.salesforce.com/forums/ForumsMain?id=906F000000097NWIAY
https://developer.salesforce.com/forums/ForumsMain?id=906F00000008xJIIAY
http://www.sfdcpoint.com/salesforce/select-all-checkbox-using-javascript-in-visualforce-page/

Please mark this as solution by selecting it as best answer if this solves your problem, So that if anyone has this issue this post can help

Thanks
Amit Chaudhary
amit.salesforce21@gmail.com