Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 79901

Set Owner of notes in plugin

$
0
0

Hi All,

I am trying to copy notes from lead to Opportunity, when lead gets qualify, so on creation of Opportunity i have plugin which copy notes from Lead with all the information show in below query.

string strFetchNotes = @"<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>
<entity name='annotation'>
<attribute name='createdby' />
<attribute name='createdon' />
<attribute name='modifiedon' />
<attribute name='modifiedby' />
<attribute name='ownerid' />
<attribute name='subject' />
<attribute name='notetext' />
<attribute name='documentbody' />
<attribute name='filename' />
<attribute name='annotationid' />
<order attribute='subject' descending='false' />
<link-entity name='lead' from='leadid' to='objectid' alias='aa'>
<filter type='and'>
<condition attribute='leadid' operator='eq' value='{0}' />
</filter>
</link-entity>
</entity>
</fetch>";

Now  i am able to create the notes but i am not able to set the owner or created by of the notes. It always set owner = user who qualify lead, but i want notes owner to be same as on lead.

Below is the code to set the owner of the notes(currently i am using )

Entity annotation = new Entity("annotation");
annotation["objectid"] = new EntityReference("opportunity", new Guid("DA5F1AD4-1FC5-E711-A82C-000D3A13A671"));
annotation["objecttypecode"] = 3;
annotation["subject"] = entNote.GetAttributeValue<string>("subject");
annotation["notetext"] = entNote.GetAttributeValue<string>("notetext");
annotation["modifiedby"] = new EntityReference("user", ((EntityReference)entNote.Attributes["modifiedby"]).Id);
annotation["createdby"]= new EntityReference("user", ((EntityReference)entNote.Attributes["createdby"]).Id);
annotation["ownerid"] = new EntityReference("user", ((EntityReference)entNote.Attributes["ownerid"]).Id);
Guid noteid = _serviceProxy.Create(annotation);

Thanks,

Shahbaaz


Viewing all articles
Browse latest Browse all 79901

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>