Today we look at the changes in the API. In the new system, some frequently used data processing APIs are removed, such as: Setstaterequest, Setbusinessunitrequest, setparentbusinessunitrequest, etc.
Now that we do this type of operation, we don't need to call these APIs separately, we can directly construct the entity object we expect. and push it to the server. The system will install its contents to do the corresponding processing.
As the saying goes, laymen look lively. Insiders look at doorways.
Despite the simple removal of several APIs, the internal architecture of the new system should have undergone massive refactoring.
For our developers. This adjustment is absolutely good news, as we can redesign the system script or the data interface. Greatly reduce the number of interactions with the server, that is, suppose we use this new change to refactor the previous interface program. The performance will be greatly improved.
This article will not discuss all the changes involved in the API, but rather the introduction of several of our daily 80% will use the Api:assignrequest and setstaterequest. The introduction of how they should be used after adjustment, for everyone to play a starting effect.
To take the following code snippet, here we have 2 operations on a customer record: assigning and setting properties. It is also possible to find that all of these operations are implemented at the entity level and do not invoke additional requests.
//set StateEntity testentity =NULL; Guid userId = Guid.parse ("{7651c7af-8b18-e511-80e0-3863bb2e8c90}"); Guid userId2 = Guid.parse ("{461c2001-c724-4dfe-ba6e-ed2d274784d2}"); Guid Teamid=guid.parse ("{BC2D90A5-F221-E511-80E1-3863BB2E7CD8}"); Guid Parentbuid=guid.parse ("{4FE4929F-F221-E511-80E1-3863BB2E7CD8}"); Guid Buid=guid.parse ("{A4448DF6-F221-E511-80E1-3863BB2E7CD8}"); QueryExpression QUERY4ACC =NewQueryExpression ("Account"); Query4acc.columnset =NewColumnSet (true); Entitycollection accounts = crmsvc_online.retrievemultiple (QUERY4ACC);if(Accounts. Entities.count >0) {testentity = accounts. entities[0]; }//set owner if(Testentity! =NULL) {testentity["ownerID"] =NewEntityReference ("SystemUser", userId); }//set State if(Testentity! =NULL) {testentity["Statecode"] =NewOptionsetvalue (1); testentity["StatusCode"] =NewOptionsetvalue (2); } crmsvc_online.update (testentity);
Of course, today the system only reconstructs a few APIs, I believe that with the new, the system will be more convenient development experience for the vast number of developers. The following is an API that already supports entity level invocation. Of course, its API will be discarded: D
- Assignrequest–> Entity.owerid
- Setstaterequest–>entity.statecode
- Setparentsystemuserrequest–>systemuser.parentsystemuserid
- Setparentteamrequest–>team.businessunitid
- Setparentbusinessunitrequest–>businessunit
- Setbusinessequipmentrequest–>equipment.businessunitid
- Setbusinesssystemuserrequest–>systemuser.businessunitid
Dynamics CRM Update 1 Series (3): What's in the API-old APIs VS New APIs