Salesforce custom object with custom field and standard field - salesforce

I have one custom object 'Territory__c' which have standard Field "Name" and custom field "Territory_Ex_ID__c". So what would be SOQL whole data. Suppose the user list I want to fetch with this detail included.
I am new to salesforce, so please help me with scenario.

for fetching the field you just have to use there API names like in your example like
Select Name, Territory_Ex_ID__c from Territory__c

List<Territory__c> list = [Select Name, Territory_Ex_ID__c from Territory__c];

Related

How use one field of a form to populate other fields in Bonita?

I have a form variable of type external API called customersList. It is a list of customer objects. In my form, I have a Customer Name and Customer Id. For the Customer Name, I use an auto-complete widget. So, when I type something in the Customer Name field, it will give me a list of suggestions. When I click on one of the suggestion, I want the Customer Id field automatically populated with the information corresponding to the name I choose.
For example, the first object of a customersList variable which is:
customersList[0] = { "customerName" = "One Time Customer", "customerNumber" = "0000" }
Thus, when I choose Customer Name field to be One Time Customer, I want the Customer Id to be set to 0000 automatically.
I set the value of the Customer Id field to be customersList[0].customerNumber. But, it is static.
(please note: customerNumber represents Customer Id)
Any tips on how to do it?
Sadly the default autocomplete widget won't let you achieve such use case.
In fact the default autocomplete widget can take a list of JSON object as "Available values", can use one of the attribute of those objects as the display value ("Displayed key" property) and use it for autocompletion but it will only store this value (i.e. the one being displayed).
In your use case it means that you can use your customersList for "Available values" and customerName for "Displayed key" but you will only be able to save the customerName in "Value".
The good news is that a custom widget that do just what you want is available as a community contribution. Checkout the project page to download it and then import it in your UI Designer. An example of usage of this custom widget is also available for download from the project releases.

Sales Force sending email to non user with template from custom object

I'm need to create email in Sales Force with the recipient as a custom object rather than a User, Contact or Person. Unfortunately, it appears my client has created a custom object for the entity we need to contact.
I tried several methods in the UI and they have all ended up needing a User or Contact record to succeed.
I'm now using APEX code in a trigger, it also requires a User, but I have managed to get past that using this work around: Sending Emails in Salesforce to Non-Contacts Using Apex
Now I need to pass my custom object into the Email Template to get the merge fields from it.
I believe setWhatId is the correct approach, but it returns "Invalid entity type for whatId".
Not sure where to turn now....
In short, I have a custom object that is not a user or a contact, but it does have a related custom object with an email address field (also not user or contact).
I need to send an email to the email address recorded on the related custom object passing the custom object to the template to gain its merge fields.
Any help or guidance would be much appreciated. Can I even do this?
Best Regards,
Rod
From your comment and without knowing much more, the relationship traversal should look like this:
Contact c = [select id, Email from Contact where id=q.Client__r.Participant_Portal_Contact__r.id limit 1];
Assuming that the email address field is on a parent object you dont need to do this with code you can probably do this using a Visualforce Email template and the relatedTo set to the object with the details you want to use as merge fields. That way you can use it in workflow or process builder or flows without the need for code

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

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.

How to get custom fields list with describeSObject on Salesforce

I am using describeSObject to get the fields list of the object "contact".
However, while I have created some custom fields in the contact object, these custom fields don't appear in the fields list returned when looping on the fields property.
$fields = $mySforceConnection->describeSObject('contact');
foreach($fields->fields as $value){
echo $value->name.' '.$value->label."\r\n";
}
When doing so I get all the default contact object fields, but not the custom fields I created for the object.
I can't find what I am not doing right, any idea?
Thanks in advance for your help.
describeSObject will return all fields (standard & custom) that you have access to, sounds like you might not of given your profile FLS (Field Level Security) access to your new fields.

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