Problem :- I had a requirement where If user click on a custom button on Account Page or any other Custom Object Detail page, XML should generate and user should be able to save that XML to their Desktop.
Solution:
1.Create a Custom button and add that page to the page layout.
2.Create a VF Page and controller as below:-
VF Page:
<apex:page standardController="Account" extensions="TestController" contentType="application/octet-stream"><?xml version="1.0" encoding="UTF-8"?>
<MyAccount:stuff xmlns:MyAccount="http://www.bogussite.com/namespace/myNamespace">
<apex:repeat value="{!accountName}" var="account">
<MyAccount:Account Name="{!account.Name}"/>
<!-- <MyAccount:Account AccountNumber="Act Name" value="{!account.AccountNumber}"/>-->
<MyAccount:Account Phone="{!account.Phone}"/>
<MyAccount:Account NoOfContact="{!account.noOfContacts__c}"/>
</apex:repeat>
</MyAccount:stuff>
</apex:page>
Apex Controller :
When user will click on the button it will prompt a window asking user to save the xml.
My next requirement is to add the related List record to the root of the Parent Record, Will update the same on .....
Try it and let me know in case of any issue or any improvement
Solution:
1.Create a Custom button and add that page to the page layout.
2.Create a VF Page and controller as below:-
VF Page:
<apex:page standardController="Account" extensions="TestController" contentType="application/octet-stream"><?xml version="1.0" encoding="UTF-8"?>
<MyAccount:stuff xmlns:MyAccount="http://www.bogussite.com/namespace/myNamespace">
<apex:repeat value="{!accountName}" var="account">
<MyAccount:Account Name="{!account.Name}"/>
<!-- <MyAccount:Account AccountNumber="Act Name" value="{!account.AccountNumber}"/>-->
<MyAccount:Account Phone="{!account.Phone}"/>
<MyAccount:Account NoOfContact="{!account.noOfContacts__c}"/>
</apex:repeat>
</MyAccount:stuff>
</apex:page>
Apex Controller :
public with sharing class TestController
{
public Id id{get;set;}
public Account account{get;set;}
public List<Account> accountName;
public TestController(ApexPages.StandardController controller)
{
//id = ApexPages.CurrentPage().getParameters().get('id');
}
public List<Account> getAccountName()
{
accountName = [select Name,Phone,noOfContacts__c from Account where id = :ApexPages.currentPage().getParameters().get('id')];
System.Debug('Account Name ' +accountName + 'ID = ' +id);
return accountName;
}
}
When user will click on the button it will prompt a window asking user to save the xml.
My next requirement is to add the related List record to the root of the Parent Record, Will update the same on .....
Try it and let me know in case of any issue or any improvement
No comments:
Post a Comment