I think this is not possible, but however I ask the question, maybe I have missed something.
Can we add/remove columns from an azure table?
For example by default we get those columns: PartitionKey, RowKey, Timestamp, ETag. Can I add for example another 3: FirstName, LastName, Email columns?
After that I will insert some values and I want to remove column Email and add instead column Address. Can we do this?
As Igor rightly said, Azure Tables do not have the concept of rows and columns. A table can contain zero or more entities and each entity can have a maximum of 255 attributes (an attribute is a name/value/type). Off of these 255 attributes, 3 of them are system attributes (PartitionKey, RowKey and Timestamp) which you can't update through your code. When creating an entity you define PartitionKey and RowKey and after that they become readonly properties. So when it comes to updating an entity, you can only update 252 attributes.
To manage data in an Azure Table, there's a REST API and you provide attributes of an entity in the request body. Azure Storage provides two ways by which you can update an entity - Update and Merge.
When you tell Azure Table Service to Update an entity, it simply drops all the existing attributes for that entity, and inserts the attributes defined in the request payload.
When you tell Azure Table Service to Merge an entity, it looks at the existing entity attributes and compares them with the attributes defined in the request payload. If it finds matching attributes, it simply updates those attributes. If the attributes are not present in existing entity but are defined in request payload, those attributes get added to the entity. If the attribute are present in existing entity but are not defined in request payload, they are not changed.
Now coming to your problem.
So let's say you already have an entity where you just defined PartitionKey and RowKey. Now you want to add FirstName, LastName, Email attributes. Because these attributes are not there in the entity, you can either use Merge or Replace to update the entity and these attributes will be added to the entity.
Now you want to drop Email attribute from an entity and instead add Address attribute to that entity. What you will do is perform an Update operation on that entity where your request body will have FirstName, LastName and Address attributes only (no Email attribute). When you update the entity with this request payload, Email attribute will be removed from the entity.
Azure Tables do not have "columns" as SQL tables do. Azure Tables have entities. Each entity has up to 255 properties. Most tools that let you look at an Azure table, choose to visualize the data in it tabular with columns. However, in reality, each entity (row) is a collection of properties.
Therefore, you can save objects/entities into an Azure Table with different properties, everytime you do a save. It makes things somewhat confusing, but you can do it.
HTH
I think programmatic answers given above is the best solution in terms of achieving the functionality.
But in case, you are working in the development mode and you have inserted an unnecessary attribute which you want to remove. you can do the same by using azure storage explorer.
You can export the table of choice, delete the property in the CSV file and import it back in new table. drop the existing table and rename the new table to the existing one. This is kind of a work around.
Related
i have created a HTTP post request using logic apps and inserting that in a table. so i need the row key to be 1,2, and 3 so on. when i insert first entity it Should be 1 and for next entity it should 2 so on. i have tried Guid no solution. please if someone knows share the answer.
If you really need to avoid guids, you have to use other ways to implement auto-increment, you could create a queue or a table entity with your next ids to use.
In the logic app before do insert action, read the queue or entity, increment and save it then insert with the value you read.
The below is my test logic app, use a itemid table to store the auto-increment id and insert the id as rowkey to destination table test. Then replace the entity in the itemid table with the new id value.
I am running into an issue when adding a new field to an entity. In my entity I had 526 fields, I tried to add a new one but I got the error message "Attribute xxx cannot be created because we have hit a maximum number of attributes allowed for an entity (1000)". However I only have 526 fields in the entity. Furthermore, I deleted one field I don't need anymore and I tried to add my new field but I still have the same error message even though I've deleted one field. Could anyone help me out please. I do appreciate it. Thanks !
Walloud
You will be hitting the column limit, even with only 526 fields.
You have to remember that CRM will add its own fields in addition to the ones that you have, such as ones for base currency. This can take you over the limit.
Also consider that the Filtered Views that CRM automatically creates have extra columns for lookup (name), optionset (name) and date (local) fields which can also mean you exceed the limit there.
I think your only options are to delete more fields in order to free up the room, or re-architect your entity design to split it over multiple related entities instead
Looks like you are facing the SQL Server 8k row limit
you can check the field names and verify this.
more information here:
http://mileyja.blogspot.com/2013/09/dealing-with-8k-sql-server-row-limits.html
You need to remember that some fields, such as currency will have two separate fields in SQL thus increment the column count by two for each one you create. If you have 500+ fields on a single entity then it is time to normalize the data and start breaking it out into related entities. It will be better for performance and your data in the long run.
http://en.wikipedia.org/wiki/Database_normalization
Cheers!
I am trying to create a custom Audit summary report based on a date range that needs to be emailed nightly. I've got most of it working, but need some help with getting the primary name/field/attribute for a referenced entity. I noticed in the Audit view for a referenced entity, the data is stored like 'systemuser;'. What I would like to do is grab the Primary Field (Primary Name, Primary Attribute, whatever it's called) to display on the report. Does anyone know how to find the Primary Name attribute for an entity using the MetadataSchema views in the CRM SQL database? I have found the Primary Key field by looking at the MetadataSchema.Attribute.IsPKAttribute field, but I don't see anything for the Primary Name field.
Also, I am grabbing the current values from the entities if there are no following audit entries. For the lookup fields (like owner or customer) how can I tell from the Metadata what field stores the ObjectTypeCode? For example, if I was looking up the customer on a sales order, I know I can look at CustomerIdType field to find the ObjectTypeCode, but I need to find that the field is called CustomerIdType from the metadata.
If anyone has any good references on the Metadata from the SQL side of CRM, I would greatly appreciate it.
SQL query to get primary fields for all entities
SELECT e.Name as 'entity', a.Name as 'primary field'
FROM [dbo].EntityView e
left join [dbo].AttributeView a on e.EntityId = a.EntityId
where (a.DisplayMask & 256) > 0 --256 is for primary field
order by e.name
There are two cases to get object type code of lookup
append Type to field name (i.e. CustomerIdType)
if above is not available, get it from AttributeMetadata
SELECT ReferencedEntityObjectTypeCode
FROM [Discworld_MSCRM].[dbo].[AttributeView]
where name = '<field name>' and entityid = '<entity id>'
I'm not sure what exact rules are for Type fields to exist
I have a site powered by ExpressionEngine 2.5.x, using Freeform, integrated to post form data to MS Dynamics CRM 2011. The extension is nicely scalable, I can change the mapping, all that excellent stuff. My problem is how to find mapping values for Lookup fields in MS Dynamics.
I am trying to map form fields from the site forms, into MS Dynamics. Some of the fields are Lookups, in MS Dynamics. Our mapping calls out the numerical value of the Lookup item, rather than its name. (Which is good, because ppl can change the text names in the MS Dynamics console without breaking the mapping.)
My question is: I know how to find the actual back-end field names of form fields within MS Dynamics. But how to I find the numerical values of the picklist items and lookup fields? Say I have a Lookup field, for Lead Source (called campaignid). The items are:
web
online
radio ad
flyer
word of mouth
other
I know that when I edit options in an option set, I can see their numerical value. Where can I edit options in a lookup field? I've tried looking under Settings > Customizations > Customize the System, but didn't see anything called lookup.
Lookups are pointers to entities. They do not have numerical values like regular option sets. So I guess that you will have entity called Campaign (or lead) so you can check which campaigns exist in the crm DB where each entity will have view in the DB.
Let's see if i understand your question. You don't have a Lookup option like Option Set because a lookup is consequence of a relationship 1:N between two entities. So for edit a lookup you need edit a record of a entity. In lookup fields you don't have numerical values, you have guid that represent individually a record, so in a record a lookup is stored in database as a guid. Check this video.
Check here how find this guid with the record open.
A look-up field is, roughly speaking a pointer to en entity (in C# it's referred to as EntityReference instead of Entity) and it consist mainly of a guid and logical name of something.
Usually, in the code, when you have an entity, in order to access the fields of its lookup-connected entity, you'll need to make an extra query for that.
So, if you have a Contact instance and need to see the address of its parent customer, you'll have to get the guid and logical name (in this case it'll be Account) and retrieve the data for it separately.
EDIT:
Suppose that you have created an instance of Contact entity and you'd like to access its lastName field. Then you can simply refer to it as follows.
var value = Xrm.Page.getAttribute(“lastName”).getValue();
On the same form, there's also a field that refers to an Account instance (its name is parentCustomerId. Suppose now that you'd like to get the fullName field of the Account. One could expect the following to work.
var account = Xrm.Page.getAttribute("parentCusomterId").getValue();
var name = account.getAttribute("fullName").getValue();
However, that's not going to work, because the parentCutomerId is a look-up field. It means that it only contains a guid (a pointer, a reference) identifying an other entity. You'll have to use it (the guid) in order to fetch the instance that the look-up is "mentioning". Then you'll be able to check it's properties.
I'm new in CRM 2011. So not familiar with all it functionality.
Have a question about displaying data from multiple related entities.
First Entity is a Users (contain information about user)
Second Entity is a Class (contain information about class user enrolled)
Third Entity is a Class Attendance (contain information if user attended class on specific date)
The idea is to show view with users who is enrolled in class.
To show start end dates and if user attended class or not.
Administrator should select user and change status to attended or not.
How it can be done in CRM 2011? Is it required custom development or just to View Customization using user interface in CRM?
Any suggestion or examples highly appreciated.
In Mscrm you can create a view for a single primary record type, on this view you can show fields from the primary record. You can also include secondary records that are linked via a lookup to the primary record, you can show columns of these secondary linked records. The limitation here is that you cannot link tertiary records from these secondary linked entities. The slight confusion here is that you can show the name of the tertiary entity as its a field on the secondary entity.
So to put this into the context for a real example, take the following entity model.
Contact has a 1 to Many relationship with incident (a contact can have many incidents, each incident has a lookup to contact)
Incident has a 1 to Many relationship with task (an incident can have many tasks, each task has a lookup to an incident)
So a view of tasks can;
Show all the fields from the task (task in the primary)
Show all the fields from the incident (incident is the secondary)
Show the name of a the contact, but not any other field (contact is a tertiary, but its name is shown as a field from the incident)
This is one of those things that becomes a lot clearer when you actually try it out for yourself. Its hard to say what you will be able to achieve because its not clear what your entity model is.
In any case here is how you create your own custom view.
CRM > Settings > Solutions > Your Solution > Your Entity > Views > New. There are various buttons would should hopefully be self explanatory.
Click Add Columns and it will present you with fields of the primary entity, use the Record Type drop down option to select fields from linked secondary entities.
Reading between the lines you have:
Class entity with many:many relationship to student (user), so a user can be enrolled on more than one class and a class has more than one user.
There is then a second entity for attendance which by the sound of it has a many:1 relationship to both student and class, and has a status to show attendance for a particular instance of the class on one date.
So far sounds like a good model.
Using the ideas in James' answer you ought to be doing a view of Attendances, including the name of the class and user. You might also have extra columns from the user or class to show things like when the course starts and ends, what the student's email address is etc.
Sort this view by class, then student, then attendance date and you have a pretty good view. But this won't display in any kind of hierarchy or show summaries. You might want to look at building a custom report for this instead so you can report on attendances, grouped by student and grouped by class. If you get clever you could also add filters for dates so you can look at attendances last month only, for example. You can probably do a lot of this with the built-in report wizard, for more complex or pretty versions go to SSRS