Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

How do I get the ID of a newly-create Annotation record?

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

I'm trying to create an attachment/annotation from a Word Template, and then copy it to a Sharepoint location.

I have managed to create the new Word document using the SetWordTemplate Action, but I don't know where I can get the Guid of the newly-created record.

Process.callActionFromHtml("SetWordTemplate",
[
{
key: "Target",
type: Process.Type.EntityReference,
value: new Process.EntityReference("test_entity", testEntityId)
},
{
key: "SelectedTemplate",
type: Process.Type.EntityReference,
value: new Process.EntityReference("documenttemplate", templateId)
}
],

onWordDocumentGenerated(params)

    );

However, I am not getting any output when the action is completed successfully.

How can I get the Guid of the record that has been created please?

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: How do I get the ID of a newly-create Annotation record?

    Hi David

    Thanks for your reply.

    I tried that. Unfortunately, because computers always speed up when you don't want them to, when I did the Retrieve it picked up the already-existing documents and didn't pick up the one I had just created. I thought that perhaps the Retrieve had executed too soon, so I tried to build in a Delay before doing the Retrieve, but that just created more complications.

  • Suggested answer
    Kokulan Profile Picture
    Kokulan 18,050 on at
    RE: How do I get the ID of a newly-create Annotation record?

    Hi Steve,

    As suggested above, you will have to query the annotation(Notes) records associated with that particular test_entity record, order by modifiedon desc and then get the first one in the list. You could also include the filename in your query as a filter to make your query a bit more accurate and to exclude all other notes and only get the notes with the same file name. When you use SetWordTemplate action, it sets the template name as the file name.

    I have has a similar requirement recently to implement.  I created Workflow to use the SetWordTemplate to generated the document and then I created a Flow that triggers on Create of Note record in CRM and moves the document to SharePoint. This is a no code solution but if you are interested, let me know I can point you to sample flow blog posts.

    Update : Sorry my suggested solution about using flow is only for Online. I did not realize yours is onprem.

  • Verified answer
    Dynamics365 Rocker Profile Picture
    Dynamics365 Rocker 7,755 on at
    RE: How do I get the ID of a newly-create Annotation record?

    You will get GUID of note(annotation) on post create of plugin.

    You will also get same in workflow that is registered on create of annotation.

  • David Jennaway Profile Picture
    David Jennaway 14,063 on at
    RE: How do I get the ID of a newly-create Annotation record?

    Unfortunately this action doesn't provide a useful return value. Probably the best option is to immediately retrieve the ID of the most recently create note attached to the target, which you can do with a queryexpression or fetch

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,711 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans