Identity Property in Sync Services - cocoa

can someone help me understand the identity property on an entity attribute? Im thinking of the identity property as a table "key" as in a Relational Database, but I'm guessing this is not it.
Im using core data and in my entities I have not defined any "Key" columns, and all is working fine.
But now that I have added sync services to my app, Im not sure how to use this sync attribute. My app is a task management planner, so I have an entity called task. I have an attribute called "name" , "due date" and other optional attributes. If I have 2 tasks with the same name, I want them both sync, so Im guessing the identity property wont do me good if I set it on the attribute "name". Right now I have not used it, and sync services is working fine...
So my question is, in what other scenarios should I use the identity property?

Are you using the standard definition of a task entity from Sync Services? Apple defined one fairly well:
http://developer.apple.com/library/mac/#documentation/AppleApplications/Reference/SyncServicesSchemaRef/Articles/Calendars.html
If so, there are three identity properties (summary, record id and calendar).
If you're defining your own entity (not sharing with the system entity) you can make additional attributes identity properties - I'd probably go with "name" and "due date" for sure; you could also add in a "created date" to ensure that you are able to truly create a unique value to compare records using.
In my experience, however, Sync Services has done a good job keeping track of tasks with the identity properties of the system's schema - I can't remember the last time I saw duplicate tasks coming through my own or user's data.
Tell me more about why you might not want to use the system schema but instead roll your own - I can think of pros and cons to each.

Related

Microservices for shared basic lookup data

I am new to microservices, and I need to create a "Student" service, which will get, save and also adds via a webhook from another thirdparty application
However, one of the fields i need to save is "Subject"
Normally, in SQL i would have a subject table, with things like
ID | Subject
1, Maths
2, English
3, Software
which i can use to populate drop down boxes, and in my Student table, i could have "SubjectId" field
However, if using a microservice... how would i setup my student microservice database so its independent?
then, what if I have a "CollegeCourse" service, which also needs the Subject type?
Should they both have there own 2nd database table, but doesnt that run the risk of a miss match... or maybe a nugGet package and just hardcode some enums which i can share between microservices?
Thank you
I can seem to find any suggestions or answers anywhere for this, but,

Change length of name fields

We are using Dynamics CRM 2016 on-premise. When you create a custom entity, you get a default "name" field which is a string with 100 characters. You can change that datatype during entity creation but we didn't do that.
Now we learned that 100 chars are not enough in our usecase, we would need 120 or 150.
The solution designer allows changing the string length but when we save the changes we get a generic database error.
Question: Is there a known workaround to change the string length of the main field?
Obviously, it is possible to create a new entity and copy the data from the old to the new entity. Since we have many views, forms and references between entities, this is not really feasible.
This is not possible using any conventional solutions (i.e. through the UI) due to constraints in the Database. The default name field is the primary key of the table. I encourage you to remake the entity and migrate existing data to the new entity.
If this is really not feasible then you can try to change the length of the column directly in the SQL DB, but that is unsupported so it might break the environment. If you want to try this be sure that you test this in an disposable environment.
I have never done it so I don't know the outcome but that is something that I would try.

Autonumbering in new entity

I have an custom entity which needs to have a case number for an XRM Application, can I generate a case number from the Service -> Case.
If this is not possible, how can I do this with a plugin, I've looked at the crmnumbering.codeplex.com but this doesn't support 2011, anybody outthere have a solution or should I rewrite it myself?
thanks
I've ran into this same type of issue (I need a custom # for an entity). Here's how you can do it:
Create an Entity called "Counter"
Add a field called "new_customnumber", make it a string or a number depending on what you want
Create a new record for that entity with whatever you want in the new_customnumber field (let's say "10000")
Create a plugin (EntityNumberGenerator) that goes out and grabs that record (you'll probably want to set the security on this record/entity really tight so no one can mess with the numbers)
On Create of the "custom entity" fire the plugin. Grab the value in new_customnumber save it to the "custom entity" (let's say in a "case" field) increment the new_customnumber and save it to the Counter entity.
Warning, I'm not sure how this is with concurrency. Meaning I'm not sure if 2 custom entities being created at the same time can grab the same number (I haven't ran into an issue yet). I haven't figured out a way to "lock" a field I've retrieved in a plugin (I'm not sure it's possible).
You will be unable to create a custom number for custom entities from the normal area you set a case number.
Look at the CRM2011sdk\sdk\samplecode\cs\plug-ins\accountnumberplugin.cs plugin. It's really similar to what you want.
Ry
I haven't seen one for 2011 yet. Probably easiest to write it yourself.
I've always created a database with a table with a single column which is an IDENTITY column. Write an SP to insert, save the IDENTITY value to a variable, and DELETE the row all within a transaction. Return the variable. Makes for a quick and easy plug-in and this takes care of any concurrency issues.
The performance is fast and the impact to your SQL server is minimal.

How can I add property to custom workflow activity that allows selection of another entity from workflow?

I'm working a custom workflow activity and would like to allow the user to select one of the entities available from within the workflow. This would be like selecting the entity in an update status activity. The list would include the primary entity, all of its associated parent entities, and any entities created within the workflow (e.g. if I created a task with the create activity, that task would be in the list).
Is there some way to do this?
Thanks!
Workflow has major shortcomings when it comes to things like this. You can add metadata to dependencies ( [CrmInput] and [CrmReferenceTarget("account")] ), but you'll need a property per entity you intend to support. I don't know if you could include multiple CrmReferenceTarget tags per property.
So even if you go through setting up a workflow activity with every lookup (which will require a code change for every new entity), you still have to take the care to set the right lookup in your code - and choose from ALL (not filtered based on your entity). Which is clearly not what you want.

MS CRM 4 - Custom entity with "regardingobjectid" functionality

I've made a custom entity that will work as an data modification audit (any entity modified will trigger creating an instance of this entity). So far I have the plugin working fine (tracking old and new versions of properties changed).
I'd like to also keep track of what entity this is related to. At first I added a N:1 from DataHistory to Task (eg.) and I can indeed link back to the original task (via a "new_tasksid" attribute I added to DataHistory).
The problem is every entity I want to log will need a separate attribute id (and an additional entry in the form!)
Looking at how phone, task, etc utilize a "regardingobjectid", this is what I should do. Unfortunately, when I try to add a "dataobjectid" and map it to eg Task and PhoneCall, it complains (on the second save), that the reference needs to be unique. How does the CRM get around this and can I emulate it?
You could create your generic "dataobjectid" field, but make it a text field and store the guid of the object there. You would lose the native grids for looking at the audit records, and you wouldn't be able to join these entities through advanced find, fetch or query expressions, but if that's not important, then you can whip up an ASPX page that displays the audit logs for that record in whatever format you choose and avoid making new relationships for every entity you want to audit.
CRM has a special lookup type that can lookup to many entity types. That functionality isn't available to us customizers, unfortunately. Your best bet is to add each relationship that could be regarding and hide the lookups that aren't in use for this particular entity.

Resources