Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM forum
Answered

Automatically create a Note on a Contact record when it is saved

Posted on by 34
Hello!
 
I'm hoping someone can help me with what I hope is a quick javascript!  I basic want whether a new Contact is created to use the On Save event to add a note to the record.  Just a simple note like "Contact created" would suffice! 
 
And if I did set up this event, does it work also during bulk imports?
 
  • Verified answer
    Leah Ju Profile Picture
    Leah Ju Microsoft Employee on at
    Automatically create a Note on a Contact record when it is saved
    Hi,
    You need create note record through web API:
    My example code:
    function createNote(executionContext) {
         var formContext = executionContext.getFormContext();
         var contactID = formContext.data.entity.getId().replace("{","").replace("}","");//current contact GUID
       

         var record = {};
         record["objectid_contact@odata.bind"] = "/contacts("+ contactID +")"; // Regarding
         record.subject = "Contact created"; // Text

         Xrm.WebApi.createRecord("annotation", record).then(
              function success(result) {
                   var newId = result.id;
                   console.log(newId);
              },
              function (error) {
                   console.log(error.message);
              }
         );
    }


    Test Result:



    I hope you can mark my answer verified if it answer your question! If you have any questions, please feel free to contact me.
    Regards,
    Leah
     

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,835 Super User

#2
Martin Dráb Profile Picture

Martin Dráb 225,526 Super User

#3
nmaenpaa Profile Picture

nmaenpaa 101,148

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans