Find items is SSRS by Id - reportingservices-2005

How do you find items in SSRS by ID? I tried to use the id returned by another find result, a new guid to string and small random string all of which return the same error:
The ID field has a value that is not valid. ---> Microsoft.ReportingServices.Diagnostics.Utilities.InvalidElementException: The ID field has a value that is not valid.
Here is the code:
var request = new FindItemsRequest
{
Conditions = new[] { new SearchCondition { Name = "ID", Value = "test"} },
Folder = "/"
};
return _ssrsService
.FindItems(request)
.Items
I'm using SSRS 2005.

Pretty sure this can't be done through the SSRS service. Ended up finding all objects then using LINQ to filter down to the ID I need.

The MS documentation on the FindItems method says:
Applications that use FindItems typically accept user input for specific properties and property values. The searchable properties are Name, Description, CreatedBy, CreationDate, ModifiedBy, and ModifiedDate. The items that are returned are only those for which a user has Read Properties permission.

Related

Dynamics 365 API link between ActivityPointer and activitytypecode global option set

I am reading data from the ActivityPointer entity in Dynamics 365 via the API and I want to link the activitytypecode field value to the activitypointer_activitytypecode global option set, which I believe is the correct one. However the values don't seem to match. In the ActivityPointer.activitytypecode field I have values such as:
phonecall
bulkoperation
email
appointment
task
But those values don't appear in the option set definition, using this query: GlobalOptionSetDefinitions(Name='activitypointer_activitytypecode')
The option set has the code values (e.g. 4202 for Email) and the different descriptions in all languages, but nothing matches back to the values on ActivityPointer
Optionset is just key value pairs (4202: Email and so on), If you want to get the formatted text value of optionset (Email, Fax, etc) from your web api query results - then you have to use activitytypecode#OData.Community.Display.V1.FormattedValue to get it. Read more
I recommend this article for complete understanding of CRM activities.
If you are looking for the code integer value in your resultset, that seems to be an issue and the result is not the expected one - old SO thread
The problem is that if you are reading activitytypecode in code, then you will know that you get a string value. This is the logical name of the activity entity, e.g. "email", "phonecall" etc.
If you look at the definition of activitytypecode in Power Apps then it shows it as "Entity name" (i.e. text) but using the classic solution editor it shows as the global activitypointer_activitytypecode option set, which contains values for "Email", "Phone Call" etc.
I am sure that there should be a simple way of converting from activitytypecode (i.e. entity name) to activitypointer_activitytypecode (i.e. option set), but I've yet to find it.
What I am doing is retrieving the global activitypointer_activitytypecode option set, so I have access to all of the text values. Then retrieve details about the entity indicated by activitytypecode, specifically what is of interesting is the display name. Then loop through the option set looking for a case-insensitive match on display name.
This is my C# code:
public int? GetActivityType(IOrganizationService service, string activityTypeCode)
{
// Get all activity types.
var optionSetRequest = new RetrieveOptionSetRequest()
{
Name = "activitypointer_activitytypecode"
};
var optionSetResponse = (RetrieveOptionSetResponse)service.Execute(optionSetRequest);
var optionSetMetadata = (OptionSetMetadata)optionSetResponse.OptionSetMetadata;
var optionValues = new Dictionary<string, int?>(StringComparer.OrdinalIgnoreCase);
foreach (var option in optionSetMetadata.Options)
{
foreach (var optionLabel in option.Label.LocalizedLabels)
{
optionValues[optionLabel.Label] = option.Value;
}
}
// Get the display name for the activity.
var retrieveEntityRequest = new RetrieveEntityRequest
{
EntityFilters = EntityFilters.Entity,
LogicalName = activityTypeCode
};
var retrieveEntityResponse = (RetrieveEntityResponse)service.Execute(retrieveEntityRequest);
LocalizedLabelCollection entityLabels = retrieveEntityResponse.EntityMetadata.DisplayName.LocalizedLabels;
// Look up the display name in the option set values.
foreach (var entityLabel in entityLabels)
{
if (optionValues.TryGetValue(entityLabel.Label, out int? value))
{
return (Schema.GlobalOptionSet.ActivityType?)value;
}
}
// If we get here then we've failed.
return null;
}
That is making two API calls, so best avoided in any situations where performance might be an issue. I'm not saying the code is perfect, but it hasn't let me down yet. Even so, I would recommend making do with the logical names provided by activitytypecode if you can.

what is a projection in LINQ, as in .Select()

I typically do mobile app development, which doesn't always have .Select. However, I've seen this used a bit, but I don't really know what it does or how it's doing whatever it does. It is anything like
from a in list select a // a.Property // new Thing { a.Property}
I'm asking because when I've seen code using .Select(), I was a bit confused by what it was doing.
.Select() is from method syntax for LINQ, select in your code from a in list select a is for query syntax. Both are same, query syntax compiles into method syntax.
You may see: Query Syntax and Method Syntax in LINQ (C#)
Projection:
Projection Operations - MSDN
Projection refers to the operation of transforming an object into a
new form that often consists only of those properties that will be
subsequently used. By using projection, you can construct a new type
that is built from each object. You can project a property and perform
a mathematical function on it. You can also project the original
object without changing it.
You may also see:
LINQ Projection
The process of transforming the results of a query is called
projection. You can project the results of a query after any filters
have been applied to change the type of the collection that is
returned.
Example from MSDN
List<string> words = new List<string>() { "an", "apple", "a", "day" };
var query = from word in words
select word.Substring(0, 1);
In the above example only first character from each string instance is selected / projected.
You can also select some fields from your collection and create an anonymous type or an instance of existing class, that process is called projection.
from a in list select new { ID = a.Id}
In the above code field Id is projected into an anonymous type ignoring other fields. Consider that your list has an object of type MyClass defined like:
class MyClass
{
public int Id { get; set; }
public string Name { get; set; }
public string Address { get; set; }
}
Now you can project the Id and Name to an anonymous type like:
Query Syntax:
var result = from a in list
select new
{
ID = a.Id,
Name = a.Name,
};
Method Syntax
var result = list.Select(r => new { ID = r.Id, Name = r.Name });
You can also project result to a new class. Consider you have a class like:
class TemporaryHolderClass
{
public int Id { get; set; }
public string Name { get; set; }
}
Then you can do:
Query Syntax:
var result = from a in list
select new TemporaryHolderClass
{
Id = a.Id,
Name = a.Name,
};
Method Syntax:
var result = list.Select(r => new TemporaryHolderClass
{
Id = r.Id,
Name = r.Name
});
You can also project to the same class, provided you are not trying to project to classes generated/created for LINQ to SQL or Entity Framework.
My summary is it takes results (or a subset of results) and allows you to quickly restructure it for use in the local context.
The select clause produces the results of the query and specifies the
"shape" or type of each returned element. For example, you can specify
whether your results will consist of complete Customer objects, just
one member, a subset of members, or some completely different result
type based on a computation or new object creation.
Source: http://msdn.microsoft.com/en-us/library/bb397927.aspx
There are a lot of possible uses for this but one is taking a complex object which of many other contains a property that is a string -- say Name -- and allows you to return an enumeration with just the entries of Name. I believe you can also do the opposite -- use that property ( for example) and create / return new type of object while passing in a property or properties.
It means "mapping". Map each element of a sequence to a transformed sequence. I hadn't comprehended its meaning before I looked at the image.
Where does the meaning of the word come from?
Simply, math! https://mathworld.wolfram.com/Projection.html

how can i get the values of the current item in sharepoint 2010

I have a list(registration) with fields like username,pwd ,name,age etc.
i want to send a mail to admin with all the fields (username,pwd,age etc...) when a new item is added to the custom list.i tried by using added event but i am unable to get the values of the newly added item.
it is entering into the if loop but at the next line i am getting an error object reference not set to any instance.
Thanks in advance
i am new to SharePoint
public override void ItemAdded(SPItemEventProperties properties)
{
base.ItemAdded(properties);
SPWeb oSPWeb = properties.OpenWeb();
//GETTING THE LIST NAME
String curListName = properties.ListTitle;
if (curListName == "registrtion")
{
//FETCH THE DATA OF THE NEW ADDED ITEM IN THE LIST
string EMPLOYEENAME = properties.AfterProperties["EMPLOYEENAME"].ToString();
}
}
Use this instead:
string EMPLOYEENAME = properties.ListItem["InternalFieldName"]
Make sure you use the internal name of the field, check here how to get that name:
http://sharepoint-works.blogspot.com.au/2012/06/internal-column-name-in-sharepoint-list.html

Retrieve all rows from a Windows Azure table using WPF and WP7

I've set up a local service and a Windows Azure database. I can access the Azure database and retrieve data from all rows but only from one column at at time.
The database has a table called People with each 'record' treated as a Person. One of the columns in the table is 'Name' and I can retrieve all of the names using:
public List<string> GetAllPeople()
{
string query = #"SELECT value Person.Name FROM DataEntities.People AS Person";
List<string> resultsAsStrings = new List<string>();
using (var context = new DataEntities())
{
ObjectQuery<string> results = context.CreateQuery<string>(query);
foreach (string result in results)
{
if (result != null)
{
resultsAsStrings.Add(result);
}
}
}
return resultsAsStrings;
}
How would I go about changing the query so that I could retrieve a list of ALL of the Person records with ALL columns in the table as opposed to just the name field?
Is there a better way to read data from an Azure table?
Cheers!
Edit:
When I change the query to:
#"SELECT value Person FROM DataEntities.People AS Person";
It returns null and my WP7 app crashes. (I also adjusted the code so that it accepted Person instead of string. E.G ObjectQuery
Try changing the call to CreateQuery:
From: CreateQuery<string>
To: CreateQuery<Person>
This is required because if you select a Person this won't be a string, but a Person.
Now, could you try not using the type (Person) as alias? Try something like this:
SELECT VALUE pers FROM DataEntities.People AS pers
And why don't you simply use context.People?

SP2010: how to create a list view which filters a lookup field

As the title says: in sharepoint 2010 i need to programmatically create a view which lets me filter on the items on a list (a list of person). In this person list i have a lookup field which refers to another list (projects): i need to show only the people that work on a determinated project (passed as a string)
I have created an example view using this code:
class Program
{
static void Main(string[] args)
{
using (SPSite site = new SPSite("http://dev_seventeen:999"))
{
using (SPWeb web = site.OpenWeb())
{
SPList books = web.Lists["Books"];
StringCollection fields = new StringCollection();
fields.Add("Title");
fields.Add("Publisher");
fields.Add("Autore");
var query = new XElement("Where",
new XElement("Eq",
new XElement("FieldRef", new XAttribute("Name", "Publisher")),
new XElement("Value", new XAttribute("Type", "Choice"), "Alpha")
)
).ToString(SaveOptions.DisableFormatting);
SPView view = books.Views.Add("TestView",
fields,
query,
100,
false,
false,
Microsoft.SharePoint.SPViewCollection.SPViewType.Html,
false
);
Console.WriteLine(query);
Console.ReadLine();
}
}
}
}
It filters a list named "Books" on a choice type field named "Publisher", looking for all books published by "Alpha"
What i need to know is how to filter on a lookup field instead of a chioce one, because if i just put "Lookup" instead of "Choice" in the query it doesn't work =(
Thanks
Can you use LookupID as type? That would make sure you only have one match. Check the following pages for Lookup fields, CAML & LINQ:
LINQ to CAML
Lookup fields inside out
Using CAML to query Sharepoint lists
over Lookup fields
CAML – Query Lookup Field by ID; not
by Value

Resources