Today we look at the changes in the API, the new system, the removal of some common data processing API, such as: Setstaterequest, Setbusinessunitrequest, Setparentbusinessunitrequest and so on. Now we do this type of operation does not need to call this kind of API alone, we can directly construct our desired entity object and push it to the server, the system will install its content to do the corresponding processing.
As the saying goes, laymen look at the lively, professional look at doorways. Although a few APIs are simply removed, the internal architecture of the new system should have undergone massive refactoring. For our developers, such an adjustment is absolutely good news, because we can design the system script or the data interface, greatly reduce the number of interactions with the server, that is, if we use this new change to reconstruct the previous interface program, performance will be greatly improved.
This article will not discuss all the changes involved in the API, but rather a few of our daily 80% will use the Api:assignrequest and setstaterequest. Briefly describe how they should be used after adjustment, for everyone to play a starting effect.
You can refer to the code snippet below, where we have 2 operations on a customer record: assigning and setting properties. As you can see, all of these operations are implemented at the entity level, and no additional requests are invoked.
//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, now the system only reconstructs a few APIs, I believe that with the follow-up 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 an entity level call and, 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
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Dynamics CRM Update 1 Series (3): Old APIs VS New APIs