• D ROKA
  • NEWBIE
  • 0 Points
  • Member since 2013

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies

 I want to create the Visual Force page where i can select the record from lookup and its  child records should get displayed in the datatable with  Add, Save and delete button, there should be a checkbox for every record and after selecting the checkbox it should allow me to delete that particular record. I have design VF page but its not working, code is as below -

 

**********Controller****************
public class TestPageController {

public Account acc {get;set;}

public List conlist{get;set;}
public List con{get;set;}

// Public Contact inList{get;set;}
// Public List l{get;set;}
// List conlist;

public TestPageController()
{
acc=new Account();
conList= new List();
}

public PageReference getContacts() {
con= [select id, firstname, AssistantName,Birthdate,Phone from Contact where Accountid =: acc.parentid];
system.debug('#########'+con);
conlist = new List();
for(Contact c: con)
{
conlist.add(new Contactwrapper(c,false));
}
system.debug('#########'+conlist);
return null;

}
public PageReference getSelected()
{
// conlist.clear();
for(Contactwrapper awp: conlist)
if(awp.selected == true)
{
// conlist.add(accwrapper.acc);
system.debug('********'+awp.cw.firstname);

}
return null;
}

public pageReference getDelete(){
List dList = new List();
for(Contactwrapper wrap: conlist){
if(wrap.selected == true)
{
dList.add(wrap.cw);
}
}
if(dList !=null && dList.size() >0){
delete dList;
}
return null;
}

public void getCancel(){

}

public PageReference AddRow() {
Contact conObj = new Contact();
conlist.add(new Contactwrapper(conObj,false));
return null;
}

public pageReference SaveRecord(){
List ctList = new List();
for(Contactwrapper wrap: conlist){
if(wrap.selected == true)
{
ctList.add(wrap.cw);
}
}
if(ctList!=null && ctList.size() >0){
update ctList;
}
return null;
}

public class Contactwrapper{
public Contact cw{get; set;}
public Boolean selected{get; set;}

public Contactwrapper(Contact c,boolean b){
cw = c;
selected = b;
// system.debug('********'+acc);
}
}

}


***************** VF Page ********************

<apex:page controller="TestPageController" showHeader="false" sidebar="false"> <script> function savemsg() { alert('Record saved!!') } </script> <apex:form >
<apex:pageBlock >
<apex:pageblockSection >
<apex:inputField value="{!acc.parentid}" label="Select Account"/>
</apex:pageblockSection>
<apex:pageBlockButtons location="Bottom" >
<apex:commandButton value="Show Contacts" action="{!getContacts}" reRender="table"/>

</apex:pageBlockButtons>
</apex:pageBlock>
<apex:pageBlock id="table" title="Display Contacts">
<apex:pageBlockSection >
<apex:pageBlockTable value="{!conlist}" var="c">
<apex:column headerValue="Select" >

<apex:inputCheckbox value="{!c.selected}">
<apex:actionSupport event="onclick" action="{!GetSelected}" rerender="Selected_PBS"/>
</apex:inputCheckbox>
</apex:column>
<apex:column >
<apex:inputField value="{!c.cw.firstname}"/>
</apex:column>
<apex:column >
<apex:inputfield value="{!c.cw.AssistantName}" />
</apex:column>
</apex:pageBlockTable>
</apex:pageBlockSection>
</apex:pageBlock>

<apex:pageblock title="Buttons">

<apex:pageBlockButtons location="Bottom">
<apex:commandButton value="Add New" action="{!AddRow}"/>
<apex:commandButton value="Save" action="{!SaveRecord}" onclick="savemsg()"/>
<apex:commandButton value="Delete" action="{!getDelete}"/>

</apex:pageBlockButtons>

</apex:pageblock>
</apex:form>
</apex:page>
***************************************************************************************************************************************

  • August 22, 2013
  • Like
  • 0

Below is the code for the trigger but i am getting error 

"Error: Compile Error: expecting a semi-colon, found 'Idval' at line 2 column 8"

 

trigger onUpdateOfObjectB on Object_B__c (Before insert,before update) {
set Idval=new set();
set Ids=new set();

for (Object_B__c ct: trigger.new)
{
idval.add(ct.Lookup_Object_A__c);
ids.add(ct.Id);
}

List Aclist=[select Id,Priority__c from Object_A__c where Id =:Idval];

List Bclist=new List();
List Cclist=[select Lookup_Object_B__c,Status__c from Object_C__c where Lookup_Object_B__c=:ids];

for(Object_A__c ac: Aclist)
{
for(Object_C__c cc: Cclist)
{
if(ac.Priority__c=='P1' && cc.Status__c=='Closed')
{
System.debug('SDFGsdf sdfsdf');
cc.addError('Your custom error message');
}
}
}
}

 

Can anybody help me its urgent...

  • August 21, 2013
  • Like
  • 0