Comments (15)
Take a look at this library you can do SOQL over the CustomField object and query by created date. https://github.com/afawcett/apex-toolingapi/blob/master/src/classes/ToolingAPIDemo.cls
from apex-mdapi.
Hi,
using below code i displayed all custom objects with in the pageblocktable.
page:
<apex:pageBlockTable value="{!lstWrap}" var="obj" style="width:600pt">
<apex:column headerValue="Object Name" value="{!obj.objName}"/>
<apex:column headerValue="Created date" value="{!obj.dd}"/>
/apex:pageblocktable
class:
public List lstWrap {get; set;}
constructor:
List<Schema.Sobjecttype> lst = Schema.getGlobalDescribe().values();
for(Schema.Sobjecttype s: lst){
Schema.Describesobjectresult sobj = s.getDescribe();
if(string.valueOf(s).contains('__c'))
lstwrap.add(new objWrapper(string.valueOf(s));
related wrapper Class:
public class objWrapper{
public string objName{get; set;}
//public DateTime dd{get; set;}
public objWrapper(string a, string b, string c, boolean b1)
{
objName = a;
}
}
Not single object .I displayed all custom objects with in the pageblocktable. How to add created dates to wrapper class list and an display with in the pageblocktable.
help me......
}
objects.sort();
}
from apex-mdapi.
The metadata API does not expose the create date. You will also have to use the tooling API to perform a SOQL query on the CustomField object to get this information and combine it into your wrapper class.
from apex-mdapi.
Hi afawcett,
I try to
ToolingAPI toolingAPI = new ToolingAPI();
List<ToolingAPI.CustomObject> customObjects = (List<ToolingAPI.CustomObject>)
toolingAPI.query('Select Id, DeveloperName, NamespacePrefix From CustomObject Where DeveloperName = 'Test'').records;
Here they mensioned DeveloperName(single object name)
Give me example how to query and add to wrapper list.How to use tooling api i don't no.
help me..
from apex-mdapi.
If you take another look at the example just below the SOQL for CustomObject is a query for CustomField, you can adapt this to query all CustomField's and return the FullName and the LastModifiedDate fields. Hope this helps get the information you need to include in your wrapper classes in addition to that returned by the Metadata API already.
ToolingAPI toolingAPI = new ToolingAPI();
List<ToolingAPI.CustomField> customFields= (List<ToolingAPI.CustomField>)
toolingAPI.query('Select FullName, LastModifiedDate From CustomField').records;
System.debug(customFields[0].fullName);
System.debug(customFields[0].lastModifiedDate);
NOTE: Please download again the ToolingAPI classes.
Also please know that you can also review the Tooling API documentation here.
from apex-mdapi.
Hi afawcett,
I want to Object Created Dates not fields Created Dates
help me..........
from apex-mdapi.
Have you tried updating the last sample code i gave you to use CustomObject instead of CustomField, that probably will work?
from apex-mdapi.
Like this...
ToolingAPI toolingAPI = new ToolingAPI();
List<ToolingAPI.CustomObject> customObjects= (List<ToolingAPI.CustomObject>)
toolingAPI.query('Select DeveloperName, LastModifiedDate From CustomObject').records;
System.debug(customObjects[0].DeveloperName);
System.debug(customObjects[0].lastModifiedDate);
from apex-mdapi.
Hi afacwcett,
I added above code like this,I got object created dates,but i con't able to add these dates to wrapper classlist..
ToolingAPI toolingAPI = new ToolingAPI();
List<ToolingAPI.CustomObject> customObjects= (List<ToolingAPI.CustomObject>)
toolingAPI.query('Select DeveloperName, LastModifiedDate From CustomObject').records;
List<Schema.Sobjecttype> lst = Schema.getGlobalDescribe().values();
for(Schema.Sobjecttype s: lst){
Schema.Describesobjectresult sobj = s.getDescribe();
if(string.valueOf(s).contains('__c'))
lstwrap.add(new objWrapper(string.valueOf(s),sobj.customObjects[0].lastModifiedDate));//Here how to add LastModifiedDate
}
objects.sort();
Wrapper class:
public class objWrapper{
public string objName{get; set;}
public DateTime dt{get;set;}
public objWrapper(string a,DateTime d)
{
objName = a;
dt=d;
}
How to add Querying Lastmodified date to here
lstwrap.add(new objWrapper(string.valueOf(s),sobj.customObjects[0].lastModifiedDate));
help me.......
from apex-mdapi.
What you need to do is to create a Map from the results of the SOQL query, then use it when building your wrapper list to find the date for the approprite custom object. There is an excellent topic in the Apex developers guide on programming with Map's here, https://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_collections_maps.htm.
from apex-mdapi.
Hi afacett,
Using these methods sobj.getKeyprefix(), sobj.isQueryable()) i get all object prefixes ,query true or false .Object created dates only pending.
I try to Map<Integer, SObject> m = new Map<Integer, Sobject>(){customObjects};
i am a new in Map related concepts.
please help me......
from apex-mdapi.
Have you read the Apex Developer Guide link i sent you?
You would define the Map like this...
Map<String, ToolingAPI.CustomObject> customObjectByName = new Map<String, ToolingAPI.CustomObject>();
Then iterate over the customObjects list and populate the Map.
for(ToolingAPI.CustomObject customObject : customObjects)
customObjectByName.put(customObject.developerName, customObjects);
Then use the Map when you are building your wrapper list.
ToolingAPI.CustomObject customObject = customObjectByName.get(String.valueOf(s));
DateTime lastModifiedDate = customObject.lastModifiedDate;
Hope this helps.
from apex-mdapi.
Hi afawcett,
Thank you very much,Its working Super
from apex-mdapi.
Excellent! 👍
from apex-mdapi.
Hi Andrew Fawcett,
But Small problem.
Using below code i deleted objects.but permanently not deleted
public PageReference doDelete(){
MetadataService.MetadataPort service = createService();
String selectedid = System.currentPagereference().getParameters().get('p2');
List<MetadataService.Metadata> myCustomObjectList = new List<MetadataService.Metadata>();
MetadataService.CustomObject customObject = new MetadataService.CustomObject();
customObject.fullName = 'rajesh__'+selectedid+'__c';
myCustomObjectList.add(customObject);
MetadataService.AsyncResult[] results = service.deleteMetadata(myCustomObjectList);
}
When i displayed all objects in an page block table using Tooling api.All objects names come looks like below with in the pageBlock table .
DynamicForm_del
PurchaseForm_del
Master_zip_load_del
How to remove these objects permanently From Database using above code?
help me......
from apex-mdapi.
Related Issues (20)
- MetadataServiceExamples outdated
- Test Class For MetadatadeolpyController Class
- Help article to use named credentials with wrapper has been removed HOT 1
- Generate an Apex from WSDL
- GlobalValueSetTranslation HOT 2
- Update search layout task, event, activity HOT 1
- System.CalloutException: Web service callout failed: Unable to parse callout response. Apex type not found for element customizeSetup
- Apex Wrapper Metadata API Takes Time to Reflect the Change
- Can't create in production org
- Can't create a sharing rule HOT 2
- GlobalValueSetTranslation
- Can we create ApexClass natively? Any Example? HOT 1
- UserInfo.getSessionId() makes this unusable in packaged code HOT 2
- How do we update multiple profiles at once?
- LightningComponentBundle (LWC): reading/creating/updating
- Creating Apex Trigger
- Creating a MultiPicklist HOT 2
- System.CalloutException: Web service callout failed: Unable to parse callout response. Apex type not found for element includeRecordsOwnedByAll
- How To get Picklist Value according to record type for a custom object HOT 3
- Can anyone suggest on how to read the flexipage? HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from apex-mdapi.