I want to show the all the available custom object, Standard object based on custom selection - salesforce

I have some requirement to list out all the custom objects and standard object detail with label name and api name using VF page. If I choose "Custom Object", Then page should list out all the custom object with the column of label name and api name. Thanks in advance.

I believe that your use case would be best suited to using the Schema.getGlobalDescribe method. With this method you can get a list of all the fields for a given object.
Schema.getGlobalDescribe.get('Contact') returns a Schema.describeObjectResult object that can be further probed to get the field names and labels. To get a Map of all the fields on the Contact object you could call:
Schema.getGlobalDescribe().get('Contact').getDescribe().fields.getMap()
From that result you could iterate over the map to display all of the results. You would want to use an outputPanel with a nested repeat to produce the results.

Related

Rename salesforce columns from API_name to field label

When you use salesforce data that has being exported through any API, tables you get have column names in their "API_Name" format. This differs a bit from their "Filed Label" format in which they are presented on salesforce's web UI (for example on reports).
You can find what API name corresponds to any of the columns (objects) in the salesforce object manager.
My question is: is there anywhere a dictionary to map API Names back to their Filed Labels? It will be very helpful to have in JSON or anything that can be used programmatically.
It's called "describe" data. It's available for whole object (label, plural label), fields (label, picklist value translations), names of related lists.
In Apex this is a good initial reading: https://developer.salesforce.com/docs/atlas.en-us.200.0.apexcode.meta/apexcode/apex_dynamic_describe_objects_understanding.htm and for fields: https://developer.salesforce.com/docs/atlas.en-us.apexref.meta/apexref/apex_methods_system_fields_describe.htm
If you're using REST API - make GET to /services/data/v55.0/sobjects/Account/describe for example.
Have a look at https://developer.salesforce.com/docs/atlas.en-us.uiapi.meta/uiapi/ui_api_quick_start.htm too. For example if you need to build your own UI for "dependent picklists" it can be painful to read it all from "describe", https://developer.salesforce.com/docs/atlas.en-us.uiapi.meta/uiapi/ui_api_features_records_dependent_picklist.htm is bit better. And when you fetch records via this API you get fields as object with visible label and raw value (useful when displaying dates, numbers for example)

Angular Schema Form Custom Template Passing Parameter

I've been searching for a while now and can't find any examples of how I could pass a custom value to a template I created with Schema Form. I needed to create a template to allow for the label to be aligned any way the user wants it to be. I got a simple version of the template working, now I need to give the template information like where the label should be aligned and how many columns the field should take so I can have multiple fields on a single row. I've tried passing my custom fields in the field definition and retrieving it in the template from the form object.
firstName = {
labelAlign: "left"
title: "First Name"
type: "string"
}
In the sample labelAlign is the custom field that I want to access through the form object and this is part of the data that is passed through the sf-schema directive. Is there another way I can access this data in my template?
Thanks in advance.
UPDATE
If I pass the custom value in the form JSON instead of the schema JSON the value show on the form but it creates another field at the very end of the form which is not what I am looking for. I've seen schema form examples that show modifying fields in the form JSON without having this problem. Does anyone know how to make this work properly?
I found the answer to my question and want to post it here for others. The object I was looking for was form.schema. That will allow access to properties created in the schema JSON.

How to retrive perticular contacts only using Contacts API

I have added one custom attribute as "category". It's values should be 'Sales','Support' etc.
I have to retrieve only those contacts who have category as custom attributes.
I tried using below code. But It is not giving the excepted results.
ContactFeed profileFeed = contactService.getFeed(new URL("https://www.google.com/m8/feeds/contacts/"+domain+"/full/?xoauth_requestor_id="+adminEmail+"&start-index="+startIndex+"&q="+searchText),ContactFeed.class);
can anyone tell me ? Is there any way to retrieve only those contacts who have 'Category' as custom attribute.?
Yes its possible, ive done ot before with some tricks. If you include a unique string in the properties, you can then search custom properties. For example prepend # to all your custom properties, then search cor those properties that contain "#". Ive done this from apps script though not fhe raw http api.

Save error: Initial term of field expression must be a concrete SObject: MAP<String,AcctId__c>

I'm trying to get over a limitation in Salesforce where Lead objects can't have related lists that convert with the Lead over to Opportunity, Contact and Account. I have set up 4 objects of type Lookup Relationship, and created a dummy record in each.
I want to use Custom Settings to store the id of each of these dummy records, so that when the Lead converts, any custom objects can also convert to objects with Master/Detail relationships on the respective standard objects.
My trigger on Lead(after update) tries to create a Map of the Custom Settings:
Map cs = AcctId__c.getAll();
AcctId__c is the Custom Setting api name. Compile time is giving me the above message.
Now, I copied this code directly from the Salesforce documentation. What am I forgetting?
I believe that you must include the actual map definition <String,AcctId__c> after the word Map.
Check out this page.
http://www.salesforce.com/us/developer/docs/apexcode/Content/langCon_apex_collections_maps.htm

Custom Button to copy data from Opportunity into a related custom object

I have a custom object that is used for product setup that is mapped to an opportunity. It's a one to many relationship - one opportunity maps to many setup objects, but one setup object is only mapped to one opportunity.
Opportunity has some setup fields that need to act as defaults for the related custom object. Unfortunately, I cannot just specify them in a formula - getting an error.
What I would like to do is have a custom button that would allow user to click and copy all of the related setup fields from the opportunity into the custom setup object and then edit them as needed.
Any pointers or sample code are greatly appreciated!
You can achieve this with a custom button on the related list for your custom object on the opportunity detail page.
All of the fields on a standard Salesforce new/edit screen have id's associated with them. You can specify values for fields by using these ids to set GET parameters on your URL. For example if the id on the name field on your opportunity is 'opp3', the following URL will populate the name field on your new opportunity page:
https://na2.salesforce.com/006/e?opp3=Hello+World
You would have to change na2 to the correct server for your org.
The new record page URL contains the 3 character id prefix for your particular object and then '/e'. 006 is the prefix for opportunities. You will have to attempt to create a new record to see what the 3 characters are for your custom object.
You will have to capture the id's of the fields you want to populate on your custom object. You can do this by viewing the source of the new record page. For custom fields these id's will take the form of a Salesforce Id (eg. 00N40000002QhEV).
Create a new list button on your custom object and set the behavior to without header and sidebar and set the source to URL. Build up your URL with id=value pairs separated by '&' using the id you got from the page source and the insert field functionality to select the opportunity fields your wish to add in. You should end up with something like this:
/a0U/e?00N40000002QhEV={!Opportunity.Name}&00N40000002QhEW={!Opportunity.StageName}
a0U should be replaced by the correct prefix for your custom object. Then add your button to the related list for your custom object under opportunity.

Resources