Answered by:
Plugin: On Create of Annotation: ObjectId is coming null

Question
-
I created My Plugin in CRM 2011. Using Earlybound classes in c# .Net.
Register Step is "Create" of "annotation" "Post-Create" "Synchronous"
I am facing an issue with Entity(Note)(Annotation) details coming from the database in plugin execution.
I am creating Note under Opportunity for testing.
"objectTypecode" value is coming "opportunity" this is correct value.
However, "ObjectId" (Regarding) value is missing in the data........
Please guide me on how can i get that value in Plugin execution code.
Attaching the trace reference.
Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: FinalExceptionDetail: <OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts"> <ErrorCode>-2147220891</ErrorCode> <ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic"> <KeyValuePairOfstringanyType> <d2p1:key>OperationStatus</d2p1:key> <d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string">0</d2p1:value> </KeyValuePairOfstringanyType> </ErrorDetails> <Message>FinalException</Message> <Timestamp>2014-06-04T12:46:22.9962627Z</Timestamp> <InnerFault i:nil="true" /> <TraceText> [InfusionCRMFlow.Plugins: InfusionCRMFlow.Plugins.AddNotes] [abc4ff11-e3eb-e311-a9f9-005056c00008: InfusionCRMFlow.Plugins.AddNotes: Create of annotation] -----Create Note----- MessageName: Create PrimaryEntityName: annotation PrimaryEntityId: 3a1e323b-e6eb-e311-a9f9-005056c00008 BusinessUnitId: 71eed1bb-e4a7-e011-b0a0-3c4a92f7dbf6 CorrelationId: 57cab942-ecaf-43ab-a0b4-9d017780e9bd Depth: 1 Has Parent Context: True InitiatingUserId: f8b43a30-bfe1-e311-a332-005056c00008 * Input Parameters * Param[Target]: Microsoft.Xrm.Sdk.Entity IsInTransaction: True IsolationMode: 1 Mode: 0 OperationCreatedOn: 04/06/2014 12:46:22 PM OperationId: 00000000-0000-0000-0000-000000000000 Organization: InsceptionCRM(dff4249f-9863-4f50-8724-1c830ba657d1) * Output Parameters * Param[id]: 3a1e323b-e6eb-e311-a9f9-005056c00008 OwningExtension: InfusionCRMFlow.Plugins.AddNotes: Create of annotation Post Entity Images: Empty Pre Entity Images: Empty SecondaryEntityName: none * Shared Variables * Param[DefaultsAddedFlag]: True Stage: 40 UserId: f8b43a30-bfe1-e311-a332-005056c00008 * Target * Entity[modifiedby]: Entity[objectid]: Entity[modifiedon]: 04/06/2014 12:46:22 PM Entity[createdon]: 04/06/2014 12:46:22 PM Entity[owningbusinessunit]: Entity[createdby]: Entity[modifiedonbehalfby]: Null Entity[isdocument]: False Entity[objecttypecode]: opportunity Entity[subject]: PluginNOte2 Entity[annotationid]: 3a1e323b-e6eb-e311-a9f9-005056c00008 Entity[notetext]: note 2 Entity[ownerid]: Entity[isprivate]: False * Target * Entity[isdocument]: False Entity[owningbusinessunit]: Entity[objectid]: Entity[annotationid]: 3a1e323b-e6eb-e311-a9f9-005056c00008 Entity[notetext]: note 2 Entity[subject]: PluginNOte2 Entity[objecttypecode]: opportunity Entity[ownerid]: Ashish Entity[modifiedon]: 04/06/2014 12:46:22 PM Entity[owninguser]: Entity[modifiedby]: Ashish Entity[createdby]: Ashish Entity[createdon]: 04/06/2014 12:46:22 PM Note: No ContactId record found! </TraceText> </OrganizationServiceFault>
Jiten Patoliya Windows C# developer
Thursday, June 5, 2014 6:07 AM
Answers
-
Can you share a printscreen of result objectid?
Annotation myNote = entity.ToEntity<Annotation>();
myNote.ObjectId
In normal circumstances , you can get the objectid like my example. I think your registration of plugin may be wrong. Also you can check the plugin registration tool
Also i suggest you to use crm developer toolkit.It creates context , images instead of you
Polat Aydın Crm Software Developer
- Edited by Polat Aydın[MCP] Monday, June 9, 2014 7:38 AM
- Marked as answer by Jiten Patoliya Monday, June 9, 2014 8:09 AM
Monday, June 9, 2014 7:34 AM -
Now seems its working now, after restarting CRM....
Jiten Patoliya Windows C# developer
- Marked as answer by Jiten Patoliya Monday, June 9, 2014 8:09 AM
Monday, June 9, 2014 8:08 AM
All replies
-
I guess this is because note is not actually created and it is still in transaction and about to create note..
if you can register post entity image on this this and retrieve object id from post image it will give your relevant data.
check out following example article for this
http://sumedha8.blogspot.co.uk/2012/10/sample-plug-in-compare-pre-and-post.html
MayankP
My Blog
Follow Me on TwitterThursday, June 5, 2014 10:01 AMAnswerer -
I guess this is because note is not actually created and it is still in transaction and about to create note..
if you can register post entity image on this this and retrieve object id from post image it will give your relevant data.
check out following example article for this
http://sumedha8.blogspot.co.uk/2012/10/sample-plug-in-compare-pre-and-post.html
MayankP
My Blog
Follow Me on TwitterThursday, June 5, 2014 10:02 AMAnswerer -
Hi Mayank,
I tried your solution seems objectId is still coming out null.
Attaching Images of Registered Step, Registered Post Image in PluginRegister Tools.
Plugin IsolationMode: "None" because i am using webcalls to do operation, which are not allowed under SandBox mode.
Step detail: Action: "Create", Entity: "Annotation" , Seondary: "none" , Stage: POST - Operation , Mode: Sunchronous Server
Also adding image of what i received on execution. Am I Missing something ??????
-------------------------
------------------
Jiten Patoliya Windows C# developer
- Edited by Jiten Patoliya Friday, June 6, 2014 9:14 AM Extra Info added
Friday, June 6, 2014 7:37 AM -
I guess this is because note is not actually created and it is still in transaction and about to create note..
The above comment is wrong , because you are in post create message of entity and crm is already create the record.Also in pre-create message of annotation crm does not create the note entity but it creates the relation.So you can get the objectid in Pre-Create Message.
Here you see , i am in Annotation post create message , and ı try to add a note to Lead entity.I can easily reach the objectid. In addition to this you can also get the objectid in Pre Create Message of the Annotation.
BTW Can you post your code , i think you pass a point , in normal case you can reach the objectid.
- Proposed as answer by Polat Aydın[MCP] Friday, June 6, 2014 2:44 PM
- Edited by Polat Aydın[MCP] Friday, June 6, 2014 3:26 PM
Friday, June 6, 2014 2:23 PM -
Can you share a printscreen of result objectid?
Annotation myNote = entity.ToEntity<Annotation>();
myNote.ObjectId
In normal circumstances , you can get the objectid like my example. I think your registration of plugin may be wrong. Also you can check the plugin registration tool
Also i suggest you to use crm developer toolkit.It creates context , images instead of you
Polat Aydın Crm Software Developer
- Edited by Polat Aydın[MCP] Monday, June 9, 2014 7:38 AM
- Marked as answer by Jiten Patoliya Monday, June 9, 2014 8:09 AM
Monday, June 9, 2014 7:34 AM -
Now seems its working now, after restarting CRM....
Jiten Patoliya Windows C# developer
- Marked as answer by Jiten Patoliya Monday, June 9, 2014 8:09 AM
Monday, June 9, 2014 8:08 AM