Answered by:
Create a Note when saving form

Question
-
Hello,
For our roles, only certain people have edit capability for Notes. Because of this, there are issues that if they leave the Notes tab to go to another window, what they have entered, so far in the current note gets saved, even if they were not done.
I was thinking of adding a Note Entry field above the Notes so that the user can write away. When the lead is saved is when I want to add what is in this field to a new note in the Notes. I also want to clear out the Note Entry field.
Can I create a Note from the OnSave of the form? If so, could you give me an example of the code that I would need?
Thanks for your help in advance!!
Eddi Rae
Monday, August 2, 2010 8:26 PM
Answers
-
Hi, Eddi.
Actually you don't need any code. You can create workflow for this purposes. Every time Note Entry field is edited workflow is triggered and it creates note regarding lead.
Microsoft CRM Freelancer
My blog (english)
Мой блог (русскоязычный)- Marked as answer by Donna EdwardsMVP Wednesday, September 1, 2010 6:26 PM
Monday, August 2, 2010 8:51 PMModerator -
Here is a screenshot how to do it using workflow:
http://lh5.ggpht.com/_73OmG38HHME/TFgoP3nByhI/AAAAAAAAAqA/jrurr82w4jA/NoteCreation1.JPG
http://lh4.ggpht.com/_73OmG38HHME/TFgoQGM7LKI/AAAAAAAAAqE/5gmnTlrbFo8/NoteCreation2.JPG
http://lh3.ggpht.com/_73OmG38HHME/TFgoQqw4H0I/AAAAAAAAAqI/L0Vtjj0O7Qs/NoteCreation3.JPG
http://lh4.ggpht.com/_73OmG38HHME/TFgoQhuh2WI/AAAAAAAAAqM/naXqsPJZ6Ig/NoteCreation4.JPG
This is really easy solution without any coding.
Microsoft CRM Freelancer
My blog (english)
Мой блог (русскоязычный)- Proposed as answer by Andrii ButenkoMVP, Moderator Tuesday, August 3, 2010 2:32 PM
- Marked as answer by Jim Glass Jr Tuesday, August 3, 2010 2:37 PM
- Unmarked as answer by EddiRaeM Tuesday, August 3, 2010 4:31 PM
- Marked as answer by Donna EdwardsMVP Saturday, August 14, 2010 9:09 PM
- Unmarked as answer by EddiRaeM Monday, August 16, 2010 1:48 PM
- Unproposed as answer by EddiRaeM Monday, August 16, 2010 1:48 PM
- Marked as answer by EddiRaeM Monday, August 16, 2010 1:48 PM
- Unmarked as answer by EddiRaeM Monday, August 16, 2010 1:48 PM
- Marked as answer by Jim Glass Jr Tuesday, August 17, 2010 4:37 PM
- Unmarked as answer by EddiRaeM Tuesday, August 17, 2010 5:05 PM
- Marked as answer by Donna EdwardsMVP Wednesday, September 1, 2010 6:27 PM
Tuesday, August 3, 2010 2:32 PMModerator
All replies
-
Hi, Eddi.
Actually you don't need any code. You can create workflow for this purposes. Every time Note Entry field is edited workflow is triggered and it creates note regarding lead.
Microsoft CRM Freelancer
My blog (english)
Мой блог (русскоязычный)- Marked as answer by Donna EdwardsMVP Wednesday, September 1, 2010 6:26 PM
Monday, August 2, 2010 8:51 PMModerator -
I don't want to trigger the workflow on edit. I want to trigger when the lead is saved. I then want to create the note and clear out the NoteEntry field. I tried to use the workflow, but I didn't see how to do this. I am pretty new to CRM, so any help would be greatly appreciated.
Eddi Rae
Monday, August 2, 2010 8:56 PM -
Hi Eddi,
If you don't want to trigger the workflow on edit, antoher option is to use Plug-in for it.
Regards,
AndyTuesday, August 3, 2010 12:35 AM -
Hi Eddi,
I suggest you use plugin with pre-event registration. You can have a look on this sample
http://blogs.msdn.com/b/crm/archive/2009/02/27/creating-a-birthday-contact-list.aspxthanks
regards,
Toong Yang
http://eastoceantechnical.blogspot.com/Tuesday, August 3, 2010 5:38 AM -
Hi Eddi.
You can use OnSave of the form event. But their is only one problem that You dont have GUID / Unique id of your entity at first onSave event. Beucase You can only add notes on saved record. You can use that event if your form has already been saved. You can check this by Form Type.
// CODE //
alert(crmForm.FormType);
// END of Code
remember 1= Create Form, 2=Update Form.
If this is ok then i will send you set of code. to create note.
Regards.
Syed Naseer Ahmad, Senior Software Engineer- Proposed as answer by Donna EdwardsMVP Tuesday, August 17, 2010 2:50 PM
- Marked as answer by Jim Glass Jr Tuesday, August 17, 2010 4:36 PM
- Unmarked as answer by EddiRaeM Tuesday, August 17, 2010 5:05 PM
- Unproposed as answer by EddiRaeM Tuesday, August 17, 2010 5:06 PM
- Marked as answer by Donna EdwardsMVP Tuesday, August 17, 2010 5:59 PM
- Unmarked as answer by EddiRaeM Tuesday, August 17, 2010 6:03 PM
Tuesday, August 3, 2010 11:58 AM -
Where do I add the code? In the OnSave?
I added to OnSave and it is not compiling at all.
Tuesday, August 3, 2010 2:20 PM -
Here is a screenshot how to do it using workflow:
http://lh5.ggpht.com/_73OmG38HHME/TFgoP3nByhI/AAAAAAAAAqA/jrurr82w4jA/NoteCreation1.JPG
http://lh4.ggpht.com/_73OmG38HHME/TFgoQGM7LKI/AAAAAAAAAqE/5gmnTlrbFo8/NoteCreation2.JPG
http://lh3.ggpht.com/_73OmG38HHME/TFgoQqw4H0I/AAAAAAAAAqI/L0Vtjj0O7Qs/NoteCreation3.JPG
http://lh4.ggpht.com/_73OmG38HHME/TFgoQhuh2WI/AAAAAAAAAqM/naXqsPJZ6Ig/NoteCreation4.JPG
This is really easy solution without any coding.
Microsoft CRM Freelancer
My blog (english)
Мой блог (русскоязычный)- Proposed as answer by Andrii ButenkoMVP, Moderator Tuesday, August 3, 2010 2:32 PM
- Marked as answer by Jim Glass Jr Tuesday, August 3, 2010 2:37 PM
- Unmarked as answer by EddiRaeM Tuesday, August 3, 2010 4:31 PM
- Marked as answer by Donna EdwardsMVP Saturday, August 14, 2010 9:09 PM
- Unmarked as answer by EddiRaeM Monday, August 16, 2010 1:48 PM
- Unproposed as answer by EddiRaeM Monday, August 16, 2010 1:48 PM
- Marked as answer by EddiRaeM Monday, August 16, 2010 1:48 PM
- Unmarked as answer by EddiRaeM Monday, August 16, 2010 1:48 PM
- Marked as answer by Jim Glass Jr Tuesday, August 17, 2010 4:37 PM
- Unmarked as answer by EddiRaeM Tuesday, August 17, 2010 5:05 PM
- Marked as answer by Donna EdwardsMVP Wednesday, September 1, 2010 6:27 PM
Tuesday, August 3, 2010 2:32 PMModerator -
This works ... When I update the form, I am getting a 2 to come back.Wednesday, August 4, 2010 9:42 PM
-
I don't want to use a workflow. I would like to have it on the OnSave function. Or have a checkbox to press to say that I am ready to create the note and then do in on the OnChange of that checkbox. So, if the checkbox is checked, then I create the note and uncheck the checkbox.
Anyone have a way to code it?
Thanks!!
Eddi Rae
Wednesday, August 11, 2010 12:54 PM -
Andriy,
I looked at the workflow and this is not going to work for me.
My Notes is in a tab on the form. I tested creating a Note and it did not get posted there. I need these notes to be in the field called Notes on the tab called Notes.
Wednesday, August 11, 2010 8:02 PM -
Hi Eddi,
If you look at Andriy's 4th screenshot, you will see the 'Regarding' attribute. Make sure you have put the correct dynamic insertion in here as it is this which links the note to the parent entity from where your workflow is being fired. If you set this right, the note will appear in the notes tab.
CRM4 MBSS- Marked as answer by Donna EdwardsMVP Saturday, August 14, 2010 9:09 PM
- Unmarked as answer by EddiRaeM Monday, August 16, 2010 1:48 PM
Wednesday, August 11, 2010 8:59 PMAnswerer -
Rob, I do not want to use a workflow. I want to code it in the OnChange function of the field.
Thanks for your input, though.
Eddi Rae
Monday, August 16, 2010 1:10 PM -
Does Syed's solution above work for you? He offered to send the code using the OnSave event.
- Marked as answer by Jim Glass Jr Tuesday, August 17, 2010 4:37 PM
- Unmarked as answer by EddiRaeM Tuesday, August 17, 2010 5:04 PM
Tuesday, August 17, 2010 2:50 PM -
Donna,
Syed never sent me the code, so I haven't been able to try it.
Thanks!
Eddi Rae
Tuesday, August 17, 2010 5:05 PM -
I would ask him for it. From his post, it sounded like he was looking for confirmation that his proposed solution sounded like it would work for you
If this is ok then i will send you set of code. to create note.
If you look at his profile, then you will see his linked in account and other ways to contact him. His solution is an answer to this post. You need to add the code to the OnSave event.
- Proposed as answer by Donna EdwardsMVP Wednesday, August 18, 2010 11:03 AM
Tuesday, August 17, 2010 5:59 PM -
add attribute in you entity
you need to developed plug in which will register on create and update
in plug in create annotation entity
where you can assign your custom attribute value (text) in annotation NoText
and SET ObjectID (of Annotation entity) = entity primery key
create new annotation record
Nikkas MIcrosoft Dynamics Crm 4.0 Technology SpecialistWednesday, August 18, 2010 8:55 AM -
Donna, I haven't heard back from Syed yet.
Nikkas, what about if I have it on the OnChange of a flag that when turned on, creates the note? Also, where would I find code that actually creates an annotation record?
Thursday, August 19, 2010 1:05 PM -
I am still looking for a solution to copy data from an attribute on the form into the NOTES field. Does anyone have any suggestions?
Thanks!!
Eddi Rae
Wednesday, September 1, 2010 3:39 PM -
Since this has been going on for so long, and it looks like you need some detailed guidance, you might want to consider hiring an hour of consulting time from a Microsoft Partner who can provide the level od detail you need to get this up and running. Several here have provided a lot of good suggestions so if none of these fit your need, it is probably time to consider a different approach.
- Proposed as answer by Donna EdwardsMVP Wednesday, September 1, 2010 4:32 PM
Wednesday, September 1, 2010 4:32 PM -
I found some code from Ayaz Ahmad. The link is http://ayazahmad.wordpress.com/2008/06/11/file-attachment-to-notes-dynamics-crm-40/
This is for adding attachments, but it gives me the basis for adding the annotation as well.
Now, here is my code. It is not compiling. If there is anyone that can show me what I am doing wrong, that would be great!!
I am adding a note the lead entity. The user enters data into a text field on the form. Once complete, they click the ready to create not flag. Below is the code for the OnChange() of the flag.
I check the flag to see if ready to move. If it is, then I move it and clear the text field and the flag.
var CurDate = new Date(); if (crmForm.all.new_notesready.DataValue == true) { annotation note = new annotation(); note.subject = "Note Created on " & CurDate & " by " & userFullName; note.documentbody = crmForm.all.new_notesentry.DataValue; Guid annotationId = Lead.Create(note); crmForm.all.new_notesentry.DataValue = ""; crmForm.all.new_notesready.DataValue = false; }
Thanks for your help in advance,
Eddi Rae
Wednesday, September 1, 2010 4:57 PM -
I decided to use the workflow. This works the way that I need to do it.
Thanks for all your patience with me.
Eddi Rae
- Marked as answer by EddiRaeM Wednesday, September 1, 2010 5:19 PM
- Unmarked as answer by Donna EdwardsMVP Wednesday, September 1, 2010 6:27 PM
Wednesday, September 1, 2010 5:19 PM