i am trying to access the Report objects in apex but getting limited fields my apex source code is
public Class MyController{
public List<Report> getReports(){
List<Report> rep1 = new List<Report>();
rep1=[Select Id,Developername,Description,Name,OwnerId from Report];
return rep1;
}
}
but i want to get the value of the sObject type to which it is related to for example
1.i click on new Report
2.then select Opportunities
3.then click create
how to get this opportunity object and how to get filters applied to reports please explain it.
Unfortunately, you won't be able to get that information. According to Salesforce's doc that information isn't available via their API. Check out all the fields available here: http://www.salesforce.com/us/developer/docs/api/Content/sforce_api_objects_report.htm
Related
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 need to track changes in any property of any user but it is not working for all properties. Here is what I'm doing:
I query the list of users using that request:
https://graph.microsoft.com/v1.0/users/delta
I follow the link in #odata.nextLink then save the link in #odata.deltaLink.
I update the displayName property of a user in Office portal.
I follow the previously saved link. I can see the updated value of displayName among other basic properties of that user.
The problem is that if I do the same with the department property, the user is returned but the new department value is not included in the json.
In the documentation(https://developer.microsoft.com/en-us/graph/docs/concepts/delta_query_overview), it is said:
Updated instances are represented by their id with at least the
properties that have been updated, but additional properties may be
included.
which is not the case here.
I have also tested the jobTitle property which is not working at all, meaning that if I change its value, the delta link does not show any change at all. I suppose it is the same for many other properties..
Is there something I'm doing wrong?
I am able also to reproduce this issue. And event I specify select to display the department property, it still doesn't show in the changing result.
Based on the test, it seems that this property doesn't including in the track changes. If you have any idea or feedback about this REST, you can submit it from this link.
I have a simple entity class in a WPF application that essentially looks like this:
public class Customer : MyBaseEntityClass
{
private IList<Order> _Orders;
public virtual IList<Order> Orders
{
get { return this._Orders; }
set {this._Orders = new ObservableCollection<Order>(value);}
}
}
I'm also using the Fluent automapper in an offline utility to create an NHibernate config file which is then loaded at runtime. This all works fine but there's an obvious performance hit due to the fact that I'm not passing the original collection back to NHibernate, so I'm trying to add a convention to get NHibernate to create the collection for me:
public class ObservableListConvention : ICollectionConvention
{
public void Apply(ICollectionInstance instance)
{
Type collectionType =
typeof(uNhAddIns.WPF.Collections.Types.ObservableListType<>)
.MakeGenericType(instance.ChildType);
instance.CollectionType(collectionType);
}
}
As you can see I'm using one of the uNhAddIns collections which I understand is supposed to provide support for both the convention and INotification changes, but for some reason doing this seems to break lazy-loading. If I load a custom record like this...
var result = this.Session.Get<Customer>(id);
...then the Orders field does get assigned an instance of type PersistentObservableGenericList but its EntityId and EntityName fields are null, and attempting to expand the orders results in the dreaded "illegal access to loading collection" message.
Can anyone tell me what I'm doing wrong and/or what I need to do to get this to work? Am I correct is assuming that the original proxy object (which normally contains the Customer ID needed to lazy-load the Orders member) is being replaced by the uNhAddIns collection item which isn't tracking the correct object?
UPDATE: I have created a test project demonstrating this issue, it doesn't reference the uNhAddins project directly but the collection classes have been added manually. It should be pretty straightforward how it works but basically it creates a database from the domain, adds a record with a child list and then tries to load it back into another session using the collection class as the implementation for the child list. An assert is thrown due to lazy-loading failing.
I FINALLY figured out the answer to this myself...the problem was due to my use of ObservableListType. In NHibernate semantics a list is an ordered collection of entities, if you want to use something for IList then you want an unordered collection i.e. a Bag.
The Eureka moment for me came after reading the answer to another StackOverflow question about this topic.
I think I might be missing something, but I can't see how to use the built in multi-select picklist control for anything but sObject fields.
I'm talking about the control which features 2 list objects marked "Available" and "Selected" with arrows inbetween to moving items between the lists. This control is an easier and more discoverable way for a user to select several items then the selectList control, which needs Shift and Ctrl to select multiple items.
Page with pictured example
With a selectList I don't need a specific sObject - I can store the users selection in one off my controllers members, and I can even create a method to provide a list of valid values - this method could be hard coded, dynamically calculated or even use a query to lookup some live data.
Is there a way to use the fancy picklist control, only without any reference to a specific sObject, just a list of string values?
Unfortunately, the only way to use any of the standard field types, e.g., dates or multi-select picklists, is to have the field be backed by an SObject.
For me, when it becomes necessary to use these kinds of fields on a Visualforce page, I will create an Object specifically for the purpose of providing a back-end for the fields. In the Apex Controller, simply instantiate your Object (no need to supply any values) and reference that object's fields on the page.
While this may seem a little inefficient from the configuration side, it has a number of added benefits such as using the default UI (automatically subject to any improvements made by SFDC) and utilizing any built in validation.
If you are dead-set on not having the field be backed by an SObject, there might be some jquery multi-select options available. I've seen a lot around but haven't really tested any.
in your class:
public List<SelectOption> getStoryItems()
{
List<SelectOption> options = new List<SelectOption>();
options.add(new SelectOption('SAM','Sam I Am'));
options.add(new SelectOption('GEORGE','George of the Jungle'));
options.add(new SelectOption('DORA','Dora the Explorer'));
return options;
}
String[] stories= new String[]{};
public String[] getStories()
{
return stories;
}
public void setStories(String[] stories)
{
this.stories= stories;
}
in your page:
<apex:selectList value="{!stories}" multiselect="true">
<apex:selectOptions value="{!getStoryItems}"/>
</apex:selectList>
The results will be comma delimited, if you don't want multiple select, just set multiselect to false
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.