How to query for User Display Name using LisData.svc SharePoint Online - sql-server

As you know when using the listdata.svc people picker fields return the userID, not the display name (createdby, modifiedby). I have been looking for a way to query the userprofile svc but have found nothing helpful.
What i am looking to do, is simply convert this ID to their respected display name. I am new to using this listsvc and this was never and issue using empty data views and XSL. If anyone has an example of grabbing list data, and showing the createdby, modifiedby, or a custom people picker field and showing their name not id that would be very helpful.
Thanks in advance

This is a default behavior, for a user field, only Id property is getting returned in the result. To return all the properties of user field $expand query options needs to be applied to the query, for example:
/_vti_bin/ListData.svc/Documents?$expand=CreatedBy,ModifiedBy
In that case the projected field values for CreatedByand ModifiedBy fields (from User Information List) are returned along with the result.
To return a specific user field properties, the $select query option could be specified. For example, the following query returns DisplayName (Title property) of CreatedBy and ModifiedBy fields:
/_vti_bin/ListData.svc/Documents?$select=CreatedBy/Title,ModifiedBy/Title&$expand=CreatedBy,ModifiedBy

Related

Query of Arrays in Salesforce

I need to do 1 of two things (I believe):
1- Get a Custom Object ID so I can query it directly
2- Get a list of values of a specific field within the Object entries.
Ultimate End goal:
Add and modify rows in my custom object via external API. However to do this I need to check and make sure my new entry/row does not already exist.
What I have:
I have a custom object (called Customer_Arrays__c). It is a table that I can add new rows to (I will call entrys). Each entry has 6 or 7 fields. 1 of these fields is called (external_ID__c). This is the field I utilize to match to new incoming data to see if the entry already exists, or if it needs to add a new row to my table. This Customer_Arrays__c is a child to my opportunity I believe – it is part of every opportunity and each line item I add has a field defaulted to the opportunity.
Help I need:
1- How do I query the value of my Cutomer_Arrays__c based upon an opportunity ID?
2- How do I query a list of values in my (external_ID__c) based upon an opportunity ID?
Thanks for your help! I have read half a dozen+ posts on similar topics and am missing something. Examples of some Past try's that failed:
Select external_ID__c,FROM Custom_Arrays__c WHERE Opportunity='00...'
Select Id (Select ID, Custom_Arrays__c from Custom_Arrays__c) from Opportunity where id ='00...'
List FROM Custom_Arrays__c WHERE Opportunity='00...'
Select Id, external_ID__c, (Select external_ID__c FROM Custom_Arrays__c) WHERE Opportunity__c='00...'
Thanks again!
Only you know how did you name the lookup field (foreign key) from arrays to Opportunity. You'll need to check in setup, next to where external_ID__c is. Since it's a custom field (gets __c at the end), my guess is you went with default.
Try
SELECT Id, Name, External_Id__c
FROM Customer_Arrays__c
WHERE Opportunity__c = '006...'
Thank you eyescream, that got me almost all the way there. Turns out I also needed a __r for the parent child relationship.
Here is a snip out of my final code that works - I think it covers everything:
SELECT Field1__c, Opportunity__r.Id, Opportunity__r.Opportunity__c,
FROM Customer_Arrays__c
WHERE Opportunity__r.Id = '006...'.
Thank you so very much!!!

Data Category Visibility Issue

I am facing Data Category visibility related issue.
The scenario is i'm following -
I have One Community User which one is using for login into my community.
This User's role is Inheriting Visibility for Category Group from it's parant role and it's Visibility is No categories are visible to parent role and subordinates.
But This User's Permission set have Custom Visibility Permission is like -
All Category Group > child Category > sub child Category
for ex :
All Products > Computers > Laptops
And I am accessing lick bellow query from apex to display related article in community.
Select Id, Title, KnowledgeArticleId, Summary, CreatedDate, UrlName From KnowledgeArticleVersion WHERE Language = 'en_US' and PublishStatus='Online' WITH DATA CATEGORY Products at (Computers__c) limit 10 UPDATE VIEWSTAT
but I am not getting any articles.
getting error like --
Invalid data category name provided: Products. There is no data category matching the given developer name on the data category group: Computers__c
If anyone have solution for this please let me know.
Thank you,
Harsiddhi.
You probably have already figured this out by now, however you need to use the API name for your Group as well, i.e. 'Products' becomes 'Products__c'.
Should be something more like this:
Select Id, Title, KnowledgeArticleId, Summary, CreatedDate, UrlName From KnowledgeArticleVersion WHERE Language = 'en_US' and PublishStatus='Online' WITH DATA CATEGORY Products__c at (Computers__c)
Queries are not dependent on permission sets.
The error in the SOQL query can be looked upon at the query editor. Whenever there is a wrong API name in the query, there comes down an indication in the Query Editor under Developer Console that:
No such column 'field_name' on entity
Thus we can look back at the object fields and relationships and can ensure if the right API name is there.

How to get salesforce Activity id

I have a salesforce query that extracting users time report
SELECT ID,Logged_Date__c ,CreatedBy.Email, CreatedBy.id, CreatedBy.Name, Time_Spent_Hours__c, Activity__c, CaseId__r.CaseNumber, CaseId__r.Account.id, CaseId__r.Account.Name , Utilized__c
FROM Time_and_Placement_Tracking__c
The Activity__c returns with the activity text.
I was trying to use Activity__c.Id, Activity__r etc. but all returns with error.
Is there a way to get the Activity id?
Verify these
You need to get to the object definition and see the field info. You can use workbench or any other API tool if you are familiar with and get the object and field def's.
Check the data type for Activity__c field. It should be a lookup/master relation. If it is not, find the field which ties to Activity object.
Open the field to get the API name and use that in the query with a '__r' extension.

Ability to click through salesforce reports

I want to perform the following. I have a report of summary type with four fields say name type date and status. Report is generated based on the filter. When the report is run, it displays the list of records for that report. I want some of the field values in the report to be a hyperlink.i.e., want that to be navigated to the record detail page if i click a particular field value. Please let me know what are the options available. Here is the screenshot attached for reference.
Mostly name fields in salesforce will have hyperlink by default. For other fields if we want to have we need to have custom formula field for the object. I created a custom formula field with the HYPERLINK function.
Here is the formula
HYPERLINK(
IF(
CONTAINS($Api.Partner_Server_URL_260, 'visual'),
'https://'+
MID($Api.Partner_Server_URL_260, FIND( 'visual', $Api.Partner_Server_URL_260)-4,4)
+'salesforce.com/',
LEFT($Api.Partner_Server_URL_260, FIND( '/pagename', $Api.Partner_Server_URL_260))
) + Id ,
custom field name/ or any string
)

Selecting custom fields of "who" object using SOQL gives no such column error

I am looking for select custom fields of "who" object using SOQL in slaesforce:
As I am testing following SOQL, its working fine.
Select t.Who.FirstName, t.Status From Task t Where t.ActivityDate = TODAY AND t.Who.Type = 'Lead'
but while add any custom field of lead object(who object here) in select statement, as mentioned following query, its give error as
No such column 'LeadExtraInfo__c' on entity 'Name'.
even LeadExtraInfo field exist into Lead object
Select t.Who.FirstName, t.Who.LeadExtraInfo__c t.ActivityDate From Task t Where t.ActivityDate = YESTERDAY AND t.Who.Type = 'Lead'
The Who and What relationships on Task are not normal relationships -- they are polymorphic. This means that they can refer to different types of objects.
In the case of Who, it can refer to a Lead or a Contact. As such, you can only get to a limited subset of the fields in the relationship, namely the ones mentioned in this doc page.
To get to other fields on Lead, you'll have to query the Task first to get its WhoId, then query Lead where the Id equals that WhoId value to get those other fields.

Resources