Answered by:
How to change regarding field of notes

Question
-
I have to move all 'Notes' of an opportunity record to another opportunity record. Could anybody help me workaround for this? would it work if I change the regarding field of Note to new opportunity, if yes would there be other impact?Monday, April 7, 2014 11:11 AM
Answers
-
Hi,
You can use worflow/dialog or write a simple console application where you can fetch notes for your opportunity and update them to target another opportunity.
HTH
Our Website | Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.- Edited by HIMBAPModerator Tuesday, April 8, 2014 1:32 AM
- Proposed as answer by HIMBAPModerator Tuesday, April 8, 2014 6:05 AM
- Marked as answer by HIMBAPModerator Thursday, April 10, 2014 1:42 AM
Tuesday, April 8, 2014 1:20 AMModerator -
Hi Santhosh,
Please find the following coding for updates regarding opportunity in notes
string notesfetch=@"<fetch distinct='false' mapping='logical' output-format='xml-platform' version='1.0'>
<entity name='annotation'>
<attribute name='subject'/>
<attribute name='notetext'/>
<attribute name='filename'/>
<attribute name='annotationid'/>
<attribute name='ownerid'/>
<attribute name='annotationid'/>
<attribute name='isdocument'/>
<order descending='false' attribute='subject'/>
<link-entity name='opportunity' alias='ac' to='objectid' from='opportunity ID'>
<filter type='and'>
//here you have to change your first opportunity(from opportunity) Guid which contains notes
<condition attribute='opportunityid' value='{EB985DE8-E9A4-E311-AB7B-D89D6779D5EC}' uitype='opportunity' operator='eq'/>
</filter>
</link-entity>
</entity>
</fetch>";
EntityCollection ecollection = service.RetrieveMultiple(new FetchExpression(notesfetch));
foreach(var i in ecollection.Entities)
{
Entity notes = new Entity("annotation");
notes["annotationid"] = i.GetAttributeValue<Guid>("annotationid");
// Here you have to change your second opportunity(to opportunity) Guid
notes["objectid"] = new EntityReference("opportunity", new Guid("F7985DE8-E9A4-E311-AB7B-D89D6779D5EC"));
service.Update(notes);
Console.Write("record updated");
}
- Proposed as answer by HIMBAPModerator Tuesday, April 8, 2014 6:05 AM
- Marked as answer by HIMBAPModerator Thursday, April 10, 2014 1:42 AM
Tuesday, April 8, 2014 6:03 AM -
Hello,
Although direct update to MS CRM tables is possible technically but they are not considered as supported customization based on SDK documentation
Our Website | Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.- Proposed as answer by HIMBAPModerator Wednesday, April 9, 2014 12:30 AM
- Marked as answer by HIMBAPModerator Thursday, April 10, 2014 1:41 AM
Wednesday, April 9, 2014 12:30 AMModerator
All replies
-
Hi,
You can use worflow/dialog or write a simple console application where you can fetch notes for your opportunity and update them to target another opportunity.
HTH
Our Website | Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.- Edited by HIMBAPModerator Tuesday, April 8, 2014 1:32 AM
- Proposed as answer by HIMBAPModerator Tuesday, April 8, 2014 6:05 AM
- Marked as answer by HIMBAPModerator Thursday, April 10, 2014 1:42 AM
Tuesday, April 8, 2014 1:20 AMModerator -
Hi Santhosh,
Please find the following coding for updates regarding opportunity in notes
string notesfetch=@"<fetch distinct='false' mapping='logical' output-format='xml-platform' version='1.0'>
<entity name='annotation'>
<attribute name='subject'/>
<attribute name='notetext'/>
<attribute name='filename'/>
<attribute name='annotationid'/>
<attribute name='ownerid'/>
<attribute name='annotationid'/>
<attribute name='isdocument'/>
<order descending='false' attribute='subject'/>
<link-entity name='opportunity' alias='ac' to='objectid' from='opportunity ID'>
<filter type='and'>
//here you have to change your first opportunity(from opportunity) Guid which contains notes
<condition attribute='opportunityid' value='{EB985DE8-E9A4-E311-AB7B-D89D6779D5EC}' uitype='opportunity' operator='eq'/>
</filter>
</link-entity>
</entity>
</fetch>";
EntityCollection ecollection = service.RetrieveMultiple(new FetchExpression(notesfetch));
foreach(var i in ecollection.Entities)
{
Entity notes = new Entity("annotation");
notes["annotationid"] = i.GetAttributeValue<Guid>("annotationid");
// Here you have to change your second opportunity(to opportunity) Guid
notes["objectid"] = new EntityReference("opportunity", new Guid("F7985DE8-E9A4-E311-AB7B-D89D6779D5EC"));
service.Update(notes);
Console.Write("record updated");
}
- Proposed as answer by HIMBAPModerator Tuesday, April 8, 2014 6:05 AM
- Marked as answer by HIMBAPModerator Thursday, April 10, 2014 1:42 AM
Tuesday, April 8, 2014 6:03 AM -
Thanks Mahendra for your detailed answer. I ll check it out. One more thing I wanted to know that if I change the 'objectid' of notes from back, is it good practice?Tuesday, April 8, 2014 6:16 AM
-
Do you mean by changing it from DB, then yes it's not a good practice and that is unsupported also.Our Website | Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.Tuesday, April 8, 2014 6:37 AMModerator -
Thanks Mahendra for your prompt reply. I understood that this isn't good practice, but I didn't get that how is it unsupported. I checked it on a dummy organization and it worked. Please correct me if I am not taking care of anything.Tuesday, April 8, 2014 11:06 AM
-
Hello,
Although direct update to MS CRM tables is possible technically but they are not considered as supported customization based on SDK documentation
Our Website | Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.- Proposed as answer by HIMBAPModerator Wednesday, April 9, 2014 12:30 AM
- Marked as answer by HIMBAPModerator Thursday, April 10, 2014 1:41 AM
Wednesday, April 9, 2014 12:30 AMModerator -
ok Mahendra, got your point. Thanks.Wednesday, April 9, 2014 8:40 AM