You need to sign in to do that
Don't have an account?
Pablo_Roldan
deploy reports through metadata API
Hi All,
I am exploring the possibilities with the reports and metadata. However I didn't find anything about deploy reports into salesforce
I have tried something similar to deploy apexclasses, although it doesn't work...
APEX CLASS:
MetadataService.MetadataPort service = createService();
Any idea?
Thanks in advance,
Pablo
I am exploring the possibilities with the reports and metadata. However I didn't find anything about deploy reports into salesforce
I have tried something similar to deploy apexclasses, although it doesn't work...
APEX CLASS:
MetadataService.MetadataPort service = createService();
MetadataFiles = new List<MetadataFile>();
MetadataFile metaDataFile = new MetadataFile();
metaDataFile.fullName = 'MyReportFolder/MyNewReportMetadata';
metaDataFile.content = '<?xml version="1.0" encoding="UTF-8"?>' +
'<Report xmlns="http://soap.sforce.com/2006/04/metadata">' +
'<chart>' +
'<backgroundColor1>#FFFFFF</backgroundColor1>' +
'<backgroundColor2>#FFFFFF</backgroundColor2>' +
'<backgroundFadeDir>Diagonal</backgroundFadeDir>' +
'<chartSummaries>' +
'<axisBinding>y</axisBinding>' +
'<column>RowCount</column>' +
'</chartSummaries>' +
'<chartType>HorizontalBar</chartType>' +
'<enableHoverLabels>false</enableHoverLabels>' +
'<expandOthers>true</expandOthers>' +
'<groupingColumn>Contact$Id</groupingColumn>' +
'<location>CHART_TOP</location>' +
'<showAxisLabels>true</showAxisLabels>' +
'<showPercentage>false</showPercentage>' +
'<showTotal>false</showTotal>' +
'<showValues>false</showValues>' +
'<size>Medium</size>' +
'<summaryAxisRange>Auto</summaryAxisRange>' +
'<textColor>#000000</textColor>' +
'<textSize>12</textSize>' +
'<titleColor>#000000</titleColor>' +
'<titleSize>18</titleSize>' +
'</chart>' +
'<columns>' +
'<field>Contact$Id</field>' +
'</columns>' +
'<columns>' +
'<field>Contact$Name</field>' +
'</columns>' +
'<columns>' +
'<field>Contact$Email</field>' +
'</columns>' +
'<columns>' +
'<field>Contact$Phone</field>' +
'</columns>' +
'<description>My test report metadata</description>' +
'<filter>' +
'<criteriaItems>' +
'<column>Contact$Name</column>' +
'<operator>start with</operator>' +
'<value>p</value>' +
'</criteriaItems>' +
'</filter>' +
'<format>Summary</format>' +
'<groupingsDown>' +
'<dateGranularity>Day</dateGranularity>' +
'<field>Contact$Id</field>' +
'<sortOrder>Asc</sortOrder>' +
'</groupingsDown>' +
'<name>MyNewReportMetadata</name>' +
'<params>' +
'<name>co</name>' +
'<value>1</value>' +
'</params>' +
'<reportType>Goals__c</reportType>' +
'<scope>team</scope>' +
'<showDetails>true</showDetails>' +
'<timeFrameFilter>' +
'<dateColumn>Contact$CreatedDate</dateColumn>' +
'<interval>INTERVAL_CUSTOM</interval>' +
'</timeFrameFilter>' +
'</Report>';
MetadataFiles.add(metaDataFile);
metaDataFile = new MetadataFile();
metaDataFile.fullName = 'package.xml';
metaDataFile.content = '<?xml version="1.0" encoding="UTF-8"?>' +
'<Package xmlns="http://soap.sforce.com/2006/04/metadata">' +
'<types>' +
'<members>MyReportFolder/MyNewReportMetadata</members>' +
'<name>Report</name>' +
'</types>' +
'<version>29.0</version>' +
'</Package>';
MetadataFiles.add(metaDataFile);
MetadataFile metaDataFile = new MetadataFile();
metaDataFile.fullName = 'MyReportFolder/MyNewReportMetadata';
metaDataFile.content = '<?xml version="1.0" encoding="UTF-8"?>' +
'<Report xmlns="http://soap.sforce.com/2006/04/metadata">' +
'<chart>' +
'<backgroundColor1>#FFFFFF</backgroundColor1>' +
'<backgroundColor2>#FFFFFF</backgroundColor2>' +
'<backgroundFadeDir>Diagonal</backgroundFadeDir>' +
'<chartSummaries>' +
'<axisBinding>y</axisBinding>' +
'<column>RowCount</column>' +
'</chartSummaries>' +
'<chartType>HorizontalBar</chartType>' +
'<enableHoverLabels>false</enableHoverLabels>' +
'<expandOthers>true</expandOthers>' +
'<groupingColumn>Contact$Id</groupingColumn>' +
'<location>CHART_TOP</location>' +
'<showAxisLabels>true</showAxisLabels>' +
'<showPercentage>false</showPercentage>' +
'<showTotal>false</showTotal>' +
'<showValues>false</showValues>' +
'<size>Medium</size>' +
'<summaryAxisRange>Auto</summaryAxisRange>' +
'<textColor>#000000</textColor>' +
'<textSize>12</textSize>' +
'<titleColor>#000000</titleColor>' +
'<titleSize>18</titleSize>' +
'</chart>' +
'<columns>' +
'<field>Contact$Id</field>' +
'</columns>' +
'<columns>' +
'<field>Contact$Name</field>' +
'</columns>' +
'<columns>' +
'<field>Contact$Email</field>' +
'</columns>' +
'<columns>' +
'<field>Contact$Phone</field>' +
'</columns>' +
'<description>My test report metadata</description>' +
'<filter>' +
'<criteriaItems>' +
'<column>Contact$Name</column>' +
'<operator>start with</operator>' +
'<value>p</value>' +
'</criteriaItems>' +
'</filter>' +
'<format>Summary</format>' +
'<groupingsDown>' +
'<dateGranularity>Day</dateGranularity>' +
'<field>Contact$Id</field>' +
'<sortOrder>Asc</sortOrder>' +
'</groupingsDown>' +
'<name>MyNewReportMetadata</name>' +
'<params>' +
'<name>co</name>' +
'<value>1</value>' +
'</params>' +
'<reportType>Goals__c</reportType>' +
'<scope>team</scope>' +
'<showDetails>true</showDetails>' +
'<timeFrameFilter>' +
'<dateColumn>Contact$CreatedDate</dateColumn>' +
'<interval>INTERVAL_CUSTOM</interval>' +
'</timeFrameFilter>' +
'</Report>';
MetadataFiles.add(metaDataFile);
metaDataFile = new MetadataFile();
metaDataFile.fullName = 'package.xml';
metaDataFile.content = '<?xml version="1.0" encoding="UTF-8"?>' +
'<Package xmlns="http://soap.sforce.com/2006/04/metadata">' +
'<types>' +
'<members>MyReportFolder/MyNewReportMetadata</members>' +
'<name>Report</name>' +
'</types>' +
'<version>29.0</version>' +
'</Package>';
MetadataFiles.add(metaDataFile);
Any idea?
Thanks in advance,
Pablo
So I think that it's not possible to show reports if you didn't run these, then the only way to show these records, it's retrieving reports and using them in SOQLs.
Finally you would need to use a structure as pageBlockTable to show these like the standard view.
And I have displayed dashboard through Google Charts API.
Hopefully this can help someone, and salesforce team will change the way to use reports doing them more customizable.
Pablo.
All Answers
http://www.salesforce.com/us/developer/docs/daas/Content/commondeploymentissues.htm
Reports can be deployed with metadata API. The only consideration is that the reports which you are deploying should not belong to any private folder.
Only reports which are in public forlder can be deployed. Please refer following threads:
http://stackoverflow.com/questions/9672561/moving-reports-in-salesforce-using-force-com-ide
https://developer.salesforce.com/forums?id=906F00000008owRIAQ
Firstly, Ramu many thanks for that link, really useful. However, it's not exactly the thing that I was looking for.
Secondly, Vinita many thanks for the links as well. These links talk more about I was looking for, but not exactly.
I'm trying to create a method in Apex class which can create a report clicking only one button.
So it's nothing about the IDE, I know that it's possible to deploy almost everything through the options that you have in Force.com IDE. However I would like to have a visualforce page which has a button which executes a apex method using metadata, when you press on that.
I was looking for on the Internet, and maybe I am wrong, but I think that it could be something about the "package.xml".
My "package.xml" has the following code:
<Package xmlns="http://soap.sforce.com/2006/04/metadata">
<types>
<members>MyReportFolder/MyNewReportMetadata</members>
<name>Report</name>
</types>
<version>29.0</version>
</Package>
Pablo
As per design it is not possible to create a report from apex code, as the createable attribute is set to false for Reports object.
Many thanks for your answer, could I ask you a last question?
Would it be possible to create a report in apex code without save that report in Salesforce and then show in a visualfoce page?
Anyway, I'm going to explain me. If you see Metadata in Salesforce, you have all the resources to create a report. That is the result to have Report, ReportType, ReportFilters....
So imagine that I have create in apex code a report without save this report into Salesforce, then I would like to display this report in a VisualForce page. would there be any method to do that?
Thanks in advance,
Pablo
So I think that it's not possible to show reports if you didn't run these, then the only way to show these records, it's retrieving reports and using them in SOQLs.
Finally you would need to use a structure as pageBlockTable to show these like the standard view.
And I have displayed dashboard through Google Charts API.
Hopefully this can help someone, and salesforce team will change the way to use reports doing them more customizable.
Pablo.
https://developer.salesforce.com/blogs/developer-relations/2017/03/building-lightning-components-chart-js.html