• Meer
  • NEWBIE
  • 125 Points
  • Member since 2012

  • Chatter
    Feed
  • 5
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 25
    Questions
  • 53
    Replies

Hi,

 

I have made a VFPage and is overriden to the edit button. I am not able to update the record, as my task is to update the record and to redirect the page to the home.

 

*********CONTROLLER*********

public class Line_Manager
{
public Fin_Journal__c journal {get;set;}

//Constructors
public Line_Manager ()
{
journal = new Fin_Journal__c();
}

 

public Line_Manager (ApexPages.StandardController controller)
{
journal = new Fin_Journal__c();
}

 

//Updating Journal [View Journal]

public PageReference UpdateJournal()
{
journal = [SELECT Name FROM Fin_Journal__c WHERE id =: ApexPages.currentPage().getParameters().get('id')];
update journal;

PageReference page = new PageReference ('https://ap1.salesforce.com/a0I/o');
return page;
}

//Cancel Function
public PageReference Cancel()
{
PageReference page = new PageReference ('https://ap1.salesforce.com/a0I/o');
return page;
}

 

}

 

 

 

*********VFPage*********

 

<apex:page standardController="Fin_Journal__c" extensions="Line_Manager">
<apex:form >

<table border="0" cellspacing = "0" cellpadding= "2">
<tr><td></td></tr><tr><td></td></tr><tr>
<td><apex:image url="https://c.ap1.content.force.com/servlet/servlet.FileDownload?file=01590000000O4Wx" width="35" height="40"/></td>
<td>
<apex:outputText ><font size="1" color="#606060" face="Arial"><b>Journal</b></font></apex:outputText><br/>
<apex:outputText ><font size="5" color="Black" face="Arial"><apex:outputField value="{!Fin_Journal__c.Name}"/> </font></apex:outputText>
</td>
</tr><tr><td></td></tr><tr><td></td></tr>
</table>

<center>
<apex:commandButton value="Save" action="{!UpdateJournal}" />&nbsp;&nbsp;
<apex:commandButton value="Delete"/>&nbsp;&nbsp;
<apex:commandButton value="Cancel" action="{!Cancel}"/>
</center>

<br/>

<apex:pageBlock mode="inlineEdit" title="Journal Detail">
<apex:pageBlockSection columns="2">
<apex:outputField value="{!Fin_Journal__c.Period__c}"/>
<apex:outputLabel ></apex:outputLabel>
<apex:outputField value="{!Fin_Journal__c.Journal_Date__c}"/>
<apex:outputLabel ></apex:outputLabel>
<apex:outputField value="{!Fin_Journal__c.Card__c}"/>
<apex:outputLabel ></apex:outputLabel>
<apex:outputField value="{!Fin_Journal__c.Description__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>

<apex:pageBlock mode="inlineEdit" title="Journal Settings">
<apex:pageBlockSection columns="2">
<apex:outputField value="{!Fin_Journal__c.Journal_Name__c}"/>
<apex:outputLabel ></apex:outputLabel>
<apex:outputField value="{!Fin_Journal__c.Batch__c}"/>
<apex:outputField value="{!Fin_Journal__c.Source__c}"/>
<apex:outputField value="{!Fin_Journal__c.Currency__c}"/>
<apex:outputField value="{!Fin_Journal__c.Status__c}"/>
<apex:outputField value="{!Fin_Journal__c.Category__c}"/>
<apex:outputField value="{!Fin_Journal__c.Include_Tax__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>

</apex:form>

</apex:page>

 

 

Thanks

 

Regards,

Meer


  • March 29, 2012
  • Like
  • 0

Hi..

 

I have a custom object name Fin_Journal__c, I want to have my own VFP for Deatail View and Edit so, is it necessary to have first Recent Journal Page similar to which I have in Default. Actually I am a bit confused here that if I create my own VFP for Edit or View than how come I will get the record for which the details should be shown in that page?

 

Please help me :( 

 

Sorry for poor english. 

 

Regards,

Meer

  • March 28, 2012
  • Like
  • 0

Hi.. I am having a problem in saving the last record.. The feilds for the last record are not saving.. I have modified a code of Bob_bazard from his blog 

http://bobbuzzard.blogspot.co.uk/2011/07/managing-list-of-new-records-in.html

 

If someone can help me in this please

 

*********Controller*********

 

public class Line_Manager
{
public Fin_Journal__c journal {get;set;}
public Line__c newLine {get; set;}
public List<LineWrapper> wrappers {get; set;}
public static Integer toDelIdent {get; set;}
public static Integer addCount {get; set;}
public Boolean refreshPage {get; set;}
private Integer nextIdent=0;

public Line_Manager ()
{
journal = new Fin_Journal__c();
wrappers=new List<LineWrapper>();
wrappers.add(new LineWrapper(nextIdent++));
}

public Line_Manager (ApexPages.StandardController controller)
{
journal = new Fin_Journal__c();
wrappers=new List<LineWrapper>();
wrappers.add(new LineWrapper(nextIdent++));
}


public Fin_Journal__c GetJournal()
{
Fin_Journal__c journal = [SELECT Name, Description__c FROM Fin_Journal__c WHERE id=: ApexPages.currentPage().getParameters().get('id')];
return journal;
}

public void delWrapper()
{
Integer toDelPos=-1;
for (Integer idx=0; idx<wrappers.size(); idx++)
{
if (wrappers[idx].ident==toDelIdent)
{
toDelPos=idx;
}
}

if (-1!=toDelPos)
{
wrappers.remove(toDelPos);
}
}

public void addRows()
{
for (Integer idx=0; idx<addCount; idx++)
{
wrappers.add(new LineWrapper(nextIdent++));
}
}

public PageReference save()
{
insert journal;

List<Line__c> lines = new List<Line__c>();
for (LineWrapper wrap : wrappers)
{
wrap.line.Journal__c = journal.id;
lines.add(wrap.line);
}
insert lines;


PageReference page = new PageReference ('https://ap1.salesforce.com/a0I/o');
return page;
}

public class LineWrapper
{
public Line__c line {get; set;}
public Integer ident {get; set;}

public LineWrapper(Integer inIdent)
{
ident=inIdent;
line =new Line__c();
}
}

}

 

 

 

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

 

 

<apex:page standardController="Fin_Journal__c" extensions="Line_Manager">
<script src="../../soap/ajax/24.0/connection.js" type="text/javascript"></script>
<script type="text/javascript">
function GetDescription()
{
var queryresult = sforce.connection.query("SELECT Description__c FROM Code_Combination__c WHERE Name = '" + document.getElementById('{!$Component.MyForm:acc}').value + "'", queryresult);
var records = queryresult.getArray('records');
document.getElementById('{!$Component.MyForm:desc}').value = records [0].Description__c;
}
</script>

<apex:form id="MyForm">

<table border="0" cellspacing = "0" cellpadding= "2">
<tr><td></td></tr><tr><td></td></tr><tr>
<td><apex:image url="https://c.ap1.content.force.com/servlet/servlet.FileDownload?file=01590000000O4Wx" width="35" height="40"/></td>
<td>
<apex:outputText ><font size="1" color="#606060" face="Arial"><b>New Journal</b></font></apex:outputText><br/>
<apex:outputText ><font size="4" color="Black" face="Arial">Journal Edit</font></apex:outputText>
</td>
</tr><tr><td></td></tr><tr><td></td></tr>
</table>

<center>
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Save & New"/>
<apex:commandButton value="Cancel"/>
</center>

<table><tr><td>&nbsp;</td></tr></table>

<apex:pageBlock mode="edit">
<apex:pageblockSection columns="1" Title="Journal Details">
<apex:inputfield value="{!journal.Period__c}"/>
<apex:inputfield value="{!journal.Journal_Date__c}"/>
<apex:inputfield value="{!journal.Card__c}"/>
<apex:inputfield value="{!journal.Description__c}" style="width:270px"/>
<apex:outputLabel ></apex:outputLabel>
<apex:outputLabel ></apex:outputLabel>
</apex:pageblockSection>
</apex:pageBlock>

<apex:pageBlock mode="edit">
<apex:pageblockSection Title="Journal Settings">
<apex:inputfield value="{!journal.Journal_Name__c}"/>
<apex:outputLabel ></apex:outputLabel>
<apex:inputfield value="{!journal.Batch__c}"/>
<apex:inputfield value="{!journal.Source__c}"/>
<apex:inputfield value="{!journal.Currency__c}"/>
<apex:inputfield value="{!journal.Status__c}"/>
<apex:inputfield value="{!journal.Category__c}"/>
<apex:inputfield value="{!journal.Currency__c}"/>
<apex:outputLabel ></apex:outputLabel>
<apex:inputfield value="{!journal.Include_Tax__c}"/>
<apex:outputLabel ></apex:outputLabel>
<apex:outputLabel ></apex:outputLabel>
</apex:pageblockSection>
</apex:pageBlock>

</apex:form>

<apex:form >
<apex:pageBlock mode="edit">
<apex:pageBlockSection title="Lines" columns="1">
<apex:pageBlockTable value="{!wrappers}" var="wrapper" id="wtable">
<apex:column headerValue="Sr. #">
<apex:outputText value="{!wrapper.ident}"/>
</apex:column>
<apex:column headerValue="Account Code" style="width:30%">
<apex:inputField value="{!wrapper.line.Code_Combination__c}" style="width:90%"/>
</apex:column>
<apex:column headerValue="Description" style="width:30%">
<apex:inputField value="{!wrapper.line.Description__c}" style="width:99%"/>
</apex:column>
<apex:column headerValue="Job" style="width:20%">
<apex:inputField value="{!wrapper.line.Job__c}" style="width:87%"/>
</apex:column>
<apex:column headerValue="Debit" style="width:6%">
<apex:inputField value="{!wrapper.line.Debit__c}" style="width:99%"/>
</apex:column>
<apex:column headerValue="Credit" style="width:6%">
<apex:inputField value="{!wrapper.line.Credit__c}" style="width:99%"/>
</apex:column>
<apex:column headerValue="Action">
<apex:commandButton value="Delete" action="{!delWrapper}" rerender="wtable">
<apex:param name="toDelIdent" value="{!wrapper.ident}" assignTo="{!toDelIdent}"/>
</apex:commandButton>
</apex:column>
</apex:pageBlockTable>
<apex:commandButton value="New Line" action="{!addRows}" rerender="wtable">
<apex:param name="addCount" value="1" assignTo="{!addCount}"/>
</apex:commandButton>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>

</apex:page>


  • March 28, 2012
  • Like
  • 0

How can I achieve this thing in VfPage without refreshing the page

 

<HTML>
<HEAD>
<TITLE> Add/Remove dynamic rows in HTML table </TITLE>
<SCRIPT language="javascript">

function addRow(tableID)
{

var table = document.getElementById(tableID);

var rowCount = table.rows.length;
var row = table.insertRow(rowCount);

var cell1 = row.insertCell(0);
cell1.innerHTML = rowCount + 1;
}

</SCRIPT>
</HEAD>
<BODY>

<INPUT type="button" value="Add Row" onclick="addRow('dataTable')" />

<TABLE id="dataTable" width="70px" border="1">
<TR>
<TD> 1 </TD>
</TR>
</TABLE>

</BODY>
</HTML>

  • March 22, 2012
  • Like
  • 0

Hi.

 

I have a Visualforce page in it I have a pageblock and there is a button 'Add Line'. Now I want a grid in which  a new line should be added just for preview purpose. On the page i have a Save button, and when it is clicked I want to add all the Lines present in the grid to be saved in the Line__c object.  Can I do this in VFpage? Please provide a good example. Thank you.

 

NOTE: While adding new line in the grid I dont want to refresh the page.

 

Regards,

Meer Salman

  • March 19, 2012
  • Like
  • 0

Hi.

 

I have a Visualforce page in it I have a pageblock and there is a button 'Add Line'. Now I want a grid in which  a new line should be added just for preview purpose. On the page i have a Save button, and when it is clicked I want to add all the Lines present in the grid to be saved in the Line__c object.  Can I do this in VFpage? Please provide a good example. Thank you.

 

NOTE: While adding new line in the grid I dont want to refresh the page.

 

Regards,

Meer Salman

  • March 16, 2012
  • Like
  • 0

Hi..

 

I have a VF page which I have added in my custom control page layout.. In VF Page I have a button which save a particular record, I want to refresh the whole detail page after saving the record (i.e. onclicking the button). Can anybody help me with this how can I refresh the whole page? I searched it but didn't get the appropiate answer, however after trying most of the snippet I got my VF Page section refreshed but not the whole detail page.

 

Regards,

Meer 

  • March 14, 2012
  • Like
  • 0

Hi,

 

I have two custom objects 'Fin_Journal__c' and 'Line__c'  they both have a master detial relationship, I am not able to insert new line.  Can anybody tell me where I am making mistake?

 

public class Fin_LineManager
{
public Line__c newLine{get; set;}
public Fin_Journal__c journal ;

public Fin_LineManager(ApexPages.standardController stdn)
{
newLine = new Line__c();
journal = [SELECT id FROM Fin_Journal__c WHERE id = :ApexPages.currentPage().getParameters().get('id')];
newLine.Journal__c = journal.id;
}

public PageReference save()
{
try
{
insert newline;
}
catch (DMLException e)
{
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error creating new contact.'));
}
return null;
}
}

 

 

Regards,

 

Meer

  • March 13, 2012
  • Like
  • 0

Hi, I have the following class and page, I have added the Page in the  detail pagelayout of custom object 'Journal'. Now can anybody tell me how can I auto fill the Journal__c field in the VfPage  with the current Journal detail page. Plus I want to save this New Line for thr current Journal. Please help me

 

********** Class **********

 

public class Fin_LineManager
{

public Line__c newLine{get; set;}


public Fin_LineManager(ApexPages.standardController stdn)
{
newLine = new Line__c();

}

public PageReference save()
{
insert newLine;
return null;
}
}

 

 

********** Page **********

 

<apex:page standardController="Fin_Journal__c" extensions="Fin_LineManager">
<apex:form >

<apex:pageBlock >

 

<apex:panelGrid columns="4" cellspacing="2" cellpadding="1">

<apex:outputLabel >Journal ID: </apex:outputLabel>
<apex:outputLabel value="{!newline.Journal__c}"/>

<apex:outputLabel >Credit: </apex:outputLabel>
<apex:inputField value="{!newline.Credit__c}"/>
<apex:outputLabel >Debit: </apex:outputLabel>
<apex:inputField value="{!newline.Debit__c}"/>
<apex:outputLabel >Description: </apex:outputLabel>
<apex:inputField value="{!newline.Description__c}"/>
<apex:commandButton action="Fin_LineManager.save()" value="Save"/>
</apex:panelGrid>

 

</apex:pageBlock>

</apex:form>
</apex:page>

 

 

NOTE: I have a related list of 'Line' in the Journal Page, I want to Update and refresh that realted list as well so the user can see that New Line has been added successfully.

 

Thanks

 

Meer

  • March 12, 2012
  • Like
  • 0

Hi, I have the following class and page, I have added the Page in the  detail pagelayout of custom object 'Journal'. Now can anybody tell me how can I auto fill the Journal__c field in the VfPage  with the current Journal detail page. Plus I want to save this New Line for thr current Journal. Please help me

 

********** Class **********

 

public class Fin_LineManager
{

public Line__c newLine{get; set;}
public Fin_Journal__c newJournal{get; set;}


public Fin_LineManager(ApexPages.standardController stdn)
{
newLine = new Line__c();
newJournal = new Fin_Journal__c();
}

public PageReference save()
{
insert newLine;
return null;
}
}

 

 

********** Page **********

 

<apex:page standardController="Fin_Journal__c" extensions="Fin_LineManager">
<apex:form >

<apex:pageBlock >

 

<apex:panelGrid columns="4" cellspacing="2" cellpadding="1">

<apex:outputLabel >Journal ID: </apex:outputLabel>
<apex:outputLabel value="{!newline.Journal__c}"/>

<apex:outputLabel >Credit: </apex:outputLabel>
<apex:inputField value="{!newline.Credit__c}"/>
<apex:outputLabel >Debit: </apex:outputLabel>
<apex:inputField value="{!newline.Debit__c}"/>
<apex:outputLabel >Description: </apex:outputLabel>
<apex:inputField value="{!newline.Description__c}"/>
<apex:commandButton action="Fin_LineManager.save()" value="Save"/>
</apex:panelGrid>

 

</apex:pageBlock>

</apex:form>
</apex:page>

 

 

NOTE: I have a related list of 'Line' in the Journal Page, I want to Update and refresh that realted list as well so the user can see that New Line has been added successfully.

 

Thanks

 

Meer

  • March 12, 2012
  • Like
  • 0

HI..

 

How can I add a Visualforce Page in a PageBlock section for a custom control?

 

Regards,

 

Meer

  • March 09, 2012
  • Like
  • 0

Hi..

 

I have a custom Object named as 'Journal' in the detail view of the Journal it shows the related list of custom object 'Line', I want to change the layout of the realted list of 'Line'. Can anyone tell me how can I change the layout of this related list??

  • March 09, 2012
  • Like
  • 0

Hi.

 

Can anybody tell me how can I override List (Standard Button and Links) of a custom Object? I have created a Page by using standardcontroller="API_Name" but still I can not see it in the Visualforce page list??

 

Regards,

Meer

  • March 09, 2012
  • Like
  • 0

Hi,

 

Can I add a Visualforce page in a default detail page of custom object? 

  • March 08, 2012
  • Like
  • 0

Hi,

 

I have a custom Object named as 'Journal'. Now I want to create my own detial page for it. When I click the New button it should go to the default screen where New Journal can be created, but after saving, it should redirect to my Custom Detail Page. Is it possible? For this what I have to do and how?

 

Please help me out.

 

Regards,

 

Meer 

  • March 08, 2012
  • Like
  • 0

Hi,

 

I have a custom object named as 'Journal', it has several feilds, I want to create a visual force page in which i want to show all the details of the Selected Journal same as it is shown in detail page.. How can i achive this?

 

Following is the code for VisualForce page

 

<apex:page controller="Fin_JournalManager" id="JournalPage" tabStyle="Fin_Journal__c" >
<apex:pageBlock title="Journal Information">
<b>Journal {!Journal}.</b>
</apex:pageBlock>
<apex:detail />
</apex:page>

 

Regards,

Meer

  • March 07, 2012
  • Like
  • 0

Hi..

 

Can i modify the exsisting layout of the custom object? I want to add a PageBlock in it, is it possible? or i have to create my own detail page for a custom object? Please help me with a proper example..

 

Regards,

Meer 

  • March 07, 2012
  • Like
  • 0

Hi..

 

I want to edit the retUrl for the below url

 

<apex:commandButton value="New" action="{!URLFOR($Action.Fin_Periods__c.New)"/>

 

I concatenated the desire url : "retURL%3D%2Fapex%2FFin_Periods" by this 

 

<apex:commandButton value="New" action="{!URLFOR($Action.Fin_Periods__c.New) & "&retURL%3D%2Fapex%2FFin_Periods"}"/>


but it dint work.. 

 

Any ideas???

 

 

Regards,

Meer

  • March 06, 2012
  • Like
  • 0

Hi..

 

I have an object named as 'Periods', I want some of my specific users to edit the records which  have already been created by the Administrator, where as New Records can only be created by the Administrator. I don't know how to achieve this, I guess its simple but actually I am new to Salesforce so don't know much of the option.

 

Please help!

Thanks,

 

Meer

  • March 06, 2012
  • Like
  • 0

Hi..

 

I have an object named as 'Periods', I want some of my specific users to edit the records which are already been created by the Administrator, where as New Records can only be created by the Administrator. I don't know how to achieve this, I guess its simple but actually I am new to Salesforce so don't know much of the option.

 

Please help!

Thanks,

 

Meer

  • March 06, 2012
  • Like
  • 0

Hi,

 

I have made a VFPage and is overriden to the edit button. I am not able to update the record, as my task is to update the record and to redirect the page to the home.

 

*********CONTROLLER*********

public class Line_Manager
{
public Fin_Journal__c journal {get;set;}

//Constructors
public Line_Manager ()
{
journal = new Fin_Journal__c();
}

 

public Line_Manager (ApexPages.StandardController controller)
{
journal = new Fin_Journal__c();
}

 

//Updating Journal [View Journal]

public PageReference UpdateJournal()
{
journal = [SELECT Name FROM Fin_Journal__c WHERE id =: ApexPages.currentPage().getParameters().get('id')];
update journal;

PageReference page = new PageReference ('https://ap1.salesforce.com/a0I/o');
return page;
}

//Cancel Function
public PageReference Cancel()
{
PageReference page = new PageReference ('https://ap1.salesforce.com/a0I/o');
return page;
}

 

}

 

 

 

*********VFPage*********

 

<apex:page standardController="Fin_Journal__c" extensions="Line_Manager">
<apex:form >

<table border="0" cellspacing = "0" cellpadding= "2">
<tr><td></td></tr><tr><td></td></tr><tr>
<td><apex:image url="https://c.ap1.content.force.com/servlet/servlet.FileDownload?file=01590000000O4Wx" width="35" height="40"/></td>
<td>
<apex:outputText ><font size="1" color="#606060" face="Arial"><b>Journal</b></font></apex:outputText><br/>
<apex:outputText ><font size="5" color="Black" face="Arial"><apex:outputField value="{!Fin_Journal__c.Name}"/> </font></apex:outputText>
</td>
</tr><tr><td></td></tr><tr><td></td></tr>
</table>

<center>
<apex:commandButton value="Save" action="{!UpdateJournal}" />&nbsp;&nbsp;
<apex:commandButton value="Delete"/>&nbsp;&nbsp;
<apex:commandButton value="Cancel" action="{!Cancel}"/>
</center>

<br/>

<apex:pageBlock mode="inlineEdit" title="Journal Detail">
<apex:pageBlockSection columns="2">
<apex:outputField value="{!Fin_Journal__c.Period__c}"/>
<apex:outputLabel ></apex:outputLabel>
<apex:outputField value="{!Fin_Journal__c.Journal_Date__c}"/>
<apex:outputLabel ></apex:outputLabel>
<apex:outputField value="{!Fin_Journal__c.Card__c}"/>
<apex:outputLabel ></apex:outputLabel>
<apex:outputField value="{!Fin_Journal__c.Description__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>

<apex:pageBlock mode="inlineEdit" title="Journal Settings">
<apex:pageBlockSection columns="2">
<apex:outputField value="{!Fin_Journal__c.Journal_Name__c}"/>
<apex:outputLabel ></apex:outputLabel>
<apex:outputField value="{!Fin_Journal__c.Batch__c}"/>
<apex:outputField value="{!Fin_Journal__c.Source__c}"/>
<apex:outputField value="{!Fin_Journal__c.Currency__c}"/>
<apex:outputField value="{!Fin_Journal__c.Status__c}"/>
<apex:outputField value="{!Fin_Journal__c.Category__c}"/>
<apex:outputField value="{!Fin_Journal__c.Include_Tax__c}"/>
</apex:pageBlockSection>
</apex:pageBlock>

</apex:form>

</apex:page>

 

 

Thanks

 

Regards,

Meer


  • March 29, 2012
  • Like
  • 0

I created an object to link Opportunities to Contacts with custom fields.

I set the relation to both Opportunity and Contact to Master-Detail type.

 

I'm trying now to create a Visualforce page to link several contacts at the same time with a pageBlocktable

 

<apex:pageBlockSection title="Contact Roles" showHeader="true" collapsible="false" columns="1" id="roleList">  
<apex:pageBlockTable value="{!crs}" var="cr">
    <apex:column headerValue="Contact">
        <apex:inputField value="{!cr.Contact__c}"/>
    </apex:column>
</apex:pageBlockTable>
<apex:commandButton value="Add Row" action="{!AddRow}" reRender="roleList"/>
</apex:pageBlockSection>

 The point is that when I'm clicking on the Add Row button (which is adding a new record to the crs list in the controller) or if I click on cancel, I am blocked because the contact is mandatory (Opportunity is filled by code).

 

Is there a way to bypass this validation on Cancel or Add Row or should I change my relation to Lookup?

If I use a lookup, I will lost the cascade delete on Contacts, to have this functionality with lookups I will have then to write OnDelete and OnUndelete Triggers. Is that the better solution in your opinion?

 

thanks,

Hi.. I am having a problem in saving the last record.. The feilds for the last record are not saving.. I have modified a code of Bob_bazard from his blog 

http://bobbuzzard.blogspot.co.uk/2011/07/managing-list-of-new-records-in.html

 

If someone can help me in this please

 

*********Controller*********

 

public class Line_Manager
{
public Fin_Journal__c journal {get;set;}
public Line__c newLine {get; set;}
public List<LineWrapper> wrappers {get; set;}
public static Integer toDelIdent {get; set;}
public static Integer addCount {get; set;}
public Boolean refreshPage {get; set;}
private Integer nextIdent=0;

public Line_Manager ()
{
journal = new Fin_Journal__c();
wrappers=new List<LineWrapper>();
wrappers.add(new LineWrapper(nextIdent++));
}

public Line_Manager (ApexPages.StandardController controller)
{
journal = new Fin_Journal__c();
wrappers=new List<LineWrapper>();
wrappers.add(new LineWrapper(nextIdent++));
}


public Fin_Journal__c GetJournal()
{
Fin_Journal__c journal = [SELECT Name, Description__c FROM Fin_Journal__c WHERE id=: ApexPages.currentPage().getParameters().get('id')];
return journal;
}

public void delWrapper()
{
Integer toDelPos=-1;
for (Integer idx=0; idx<wrappers.size(); idx++)
{
if (wrappers[idx].ident==toDelIdent)
{
toDelPos=idx;
}
}

if (-1!=toDelPos)
{
wrappers.remove(toDelPos);
}
}

public void addRows()
{
for (Integer idx=0; idx<addCount; idx++)
{
wrappers.add(new LineWrapper(nextIdent++));
}
}

public PageReference save()
{
insert journal;

List<Line__c> lines = new List<Line__c>();
for (LineWrapper wrap : wrappers)
{
wrap.line.Journal__c = journal.id;
lines.add(wrap.line);
}
insert lines;


PageReference page = new PageReference ('https://ap1.salesforce.com/a0I/o');
return page;
}

public class LineWrapper
{
public Line__c line {get; set;}
public Integer ident {get; set;}

public LineWrapper(Integer inIdent)
{
ident=inIdent;
line =new Line__c();
}
}

}

 

 

 

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

 

 

<apex:page standardController="Fin_Journal__c" extensions="Line_Manager">
<script src="../../soap/ajax/24.0/connection.js" type="text/javascript"></script>
<script type="text/javascript">
function GetDescription()
{
var queryresult = sforce.connection.query("SELECT Description__c FROM Code_Combination__c WHERE Name = '" + document.getElementById('{!$Component.MyForm:acc}').value + "'", queryresult);
var records = queryresult.getArray('records');
document.getElementById('{!$Component.MyForm:desc}').value = records [0].Description__c;
}
</script>

<apex:form id="MyForm">

<table border="0" cellspacing = "0" cellpadding= "2">
<tr><td></td></tr><tr><td></td></tr><tr>
<td><apex:image url="https://c.ap1.content.force.com/servlet/servlet.FileDownload?file=01590000000O4Wx" width="35" height="40"/></td>
<td>
<apex:outputText ><font size="1" color="#606060" face="Arial"><b>New Journal</b></font></apex:outputText><br/>
<apex:outputText ><font size="4" color="Black" face="Arial">Journal Edit</font></apex:outputText>
</td>
</tr><tr><td></td></tr><tr><td></td></tr>
</table>

<center>
<apex:commandButton value="Save" action="{!save}"/>
<apex:commandButton value="Save & New"/>
<apex:commandButton value="Cancel"/>
</center>

<table><tr><td>&nbsp;</td></tr></table>

<apex:pageBlock mode="edit">
<apex:pageblockSection columns="1" Title="Journal Details">
<apex:inputfield value="{!journal.Period__c}"/>
<apex:inputfield value="{!journal.Journal_Date__c}"/>
<apex:inputfield value="{!journal.Card__c}"/>
<apex:inputfield value="{!journal.Description__c}" style="width:270px"/>
<apex:outputLabel ></apex:outputLabel>
<apex:outputLabel ></apex:outputLabel>
</apex:pageblockSection>
</apex:pageBlock>

<apex:pageBlock mode="edit">
<apex:pageblockSection Title="Journal Settings">
<apex:inputfield value="{!journal.Journal_Name__c}"/>
<apex:outputLabel ></apex:outputLabel>
<apex:inputfield value="{!journal.Batch__c}"/>
<apex:inputfield value="{!journal.Source__c}"/>
<apex:inputfield value="{!journal.Currency__c}"/>
<apex:inputfield value="{!journal.Status__c}"/>
<apex:inputfield value="{!journal.Category__c}"/>
<apex:inputfield value="{!journal.Currency__c}"/>
<apex:outputLabel ></apex:outputLabel>
<apex:inputfield value="{!journal.Include_Tax__c}"/>
<apex:outputLabel ></apex:outputLabel>
<apex:outputLabel ></apex:outputLabel>
</apex:pageblockSection>
</apex:pageBlock>

</apex:form>

<apex:form >
<apex:pageBlock mode="edit">
<apex:pageBlockSection title="Lines" columns="1">
<apex:pageBlockTable value="{!wrappers}" var="wrapper" id="wtable">
<apex:column headerValue="Sr. #">
<apex:outputText value="{!wrapper.ident}"/>
</apex:column>
<apex:column headerValue="Account Code" style="width:30%">
<apex:inputField value="{!wrapper.line.Code_Combination__c}" style="width:90%"/>
</apex:column>
<apex:column headerValue="Description" style="width:30%">
<apex:inputField value="{!wrapper.line.Description__c}" style="width:99%"/>
</apex:column>
<apex:column headerValue="Job" style="width:20%">
<apex:inputField value="{!wrapper.line.Job__c}" style="width:87%"/>
</apex:column>
<apex:column headerValue="Debit" style="width:6%">
<apex:inputField value="{!wrapper.line.Debit__c}" style="width:99%"/>
</apex:column>
<apex:column headerValue="Credit" style="width:6%">
<apex:inputField value="{!wrapper.line.Credit__c}" style="width:99%"/>
</apex:column>
<apex:column headerValue="Action">
<apex:commandButton value="Delete" action="{!delWrapper}" rerender="wtable">
<apex:param name="toDelIdent" value="{!wrapper.ident}" assignTo="{!toDelIdent}"/>
</apex:commandButton>
</apex:column>
</apex:pageBlockTable>
<apex:commandButton value="New Line" action="{!addRows}" rerender="wtable">
<apex:param name="addCount" value="1" assignTo="{!addCount}"/>
</apex:commandButton>
</apex:pageBlockSection>
</apex:pageBlock>
</apex:form>

</apex:page>


  • March 28, 2012
  • Like
  • 0

How can I achieve this thing in VfPage without refreshing the page

 

<HTML>
<HEAD>
<TITLE> Add/Remove dynamic rows in HTML table </TITLE>
<SCRIPT language="javascript">

function addRow(tableID)
{

var table = document.getElementById(tableID);

var rowCount = table.rows.length;
var row = table.insertRow(rowCount);

var cell1 = row.insertCell(0);
cell1.innerHTML = rowCount + 1;
}

</SCRIPT>
</HEAD>
<BODY>

<INPUT type="button" value="Add Row" onclick="addRow('dataTable')" />

<TABLE id="dataTable" width="70px" border="1">
<TR>
<TD> 1 </TD>
</TR>
</TABLE>

</BODY>
</HTML>

  • March 22, 2012
  • Like
  • 0

Hi.

 

I have a Visualforce page in it I have a pageblock and there is a button 'Add Line'. Now I want a grid in which  a new line should be added just for preview purpose. On the page i have a Save button, and when it is clicked I want to add all the Lines present in the grid to be saved in the Line__c object.  Can I do this in VFpage? Please provide a good example. Thank you.

 

NOTE: While adding new line in the grid I dont want to refresh the page.

 

Regards,

Meer Salman

  • March 19, 2012
  • Like
  • 0

Hi.

 

I have a Visualforce page in it I have a pageblock and there is a button 'Add Line'. Now I want a grid in which  a new line should be added just for preview purpose. On the page i have a Save button, and when it is clicked I want to add all the Lines present in the grid to be saved in the Line__c object.  Can I do this in VFpage? Please provide a good example. Thank you.

 

NOTE: While adding new line in the grid I dont want to refresh the page.

 

Regards,

Meer Salman

  • March 16, 2012
  • Like
  • 0

Hi..

 

I have a VF page which I have added in my custom control page layout.. In VF Page I have a button which save a particular record, I want to refresh the whole detail page after saving the record (i.e. onclicking the button). Can anybody help me with this how can I refresh the whole page? I searched it but didn't get the appropiate answer, however after trying most of the snippet I got my VF Page section refreshed but not the whole detail page.

 

Regards,

Meer 

  • March 14, 2012
  • Like
  • 0

Hi,

 

I have two custom objects 'Fin_Journal__c' and 'Line__c'  they both have a master detial relationship, I am not able to insert new line.  Can anybody tell me where I am making mistake?

 

public class Fin_LineManager
{
public Line__c newLine{get; set;}
public Fin_Journal__c journal ;

public Fin_LineManager(ApexPages.standardController stdn)
{
newLine = new Line__c();
journal = [SELECT id FROM Fin_Journal__c WHERE id = :ApexPages.currentPage().getParameters().get('id')];
newLine.Journal__c = journal.id;
}

public PageReference save()
{
try
{
insert newline;
}
catch (DMLException e)
{
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.ERROR,'Error creating new contact.'));
}
return null;
}
}

 

 

Regards,

 

Meer

  • March 13, 2012
  • Like
  • 0

Hi, I have the following class and page, I have added the Page in the  detail pagelayout of custom object 'Journal'. Now can anybody tell me how can I auto fill the Journal__c field in the VfPage  with the current Journal detail page. Plus I want to save this New Line for thr current Journal. Please help me

 

********** Class **********

 

public class Fin_LineManager
{

public Line__c newLine{get; set;}


public Fin_LineManager(ApexPages.standardController stdn)
{
newLine = new Line__c();

}

public PageReference save()
{
insert newLine;
return null;
}
}

 

 

********** Page **********

 

<apex:page standardController="Fin_Journal__c" extensions="Fin_LineManager">
<apex:form >

<apex:pageBlock >

 

<apex:panelGrid columns="4" cellspacing="2" cellpadding="1">

<apex:outputLabel >Journal ID: </apex:outputLabel>
<apex:outputLabel value="{!newline.Journal__c}"/>

<apex:outputLabel >Credit: </apex:outputLabel>
<apex:inputField value="{!newline.Credit__c}"/>
<apex:outputLabel >Debit: </apex:outputLabel>
<apex:inputField value="{!newline.Debit__c}"/>
<apex:outputLabel >Description: </apex:outputLabel>
<apex:inputField value="{!newline.Description__c}"/>
<apex:commandButton action="Fin_LineManager.save()" value="Save"/>
</apex:panelGrid>

 

</apex:pageBlock>

</apex:form>
</apex:page>

 

 

NOTE: I have a related list of 'Line' in the Journal Page, I want to Update and refresh that realted list as well so the user can see that New Line has been added successfully.

 

Thanks

 

Meer

  • March 12, 2012
  • Like
  • 0