Microsoft recently added functionality for one-click document generation to Dynamics 365.  Although this is great functionality, it is a bit limited with regard to where it can save the generated document.  Out of the box, we can add the SetWordTemplate action to a workflow, but that generates the document and saves it as an attachment to an annotation.  What if you want to save it in SharePoint?  We can accomplish this with a custom plugin.

Although Microsoft has added them to the online documentation, there are some actions available for us to call.

 Input ParametersOutput Parameters
ActionNameTypeNameType
ExportWordDocumentEntityTypeCodeInt32WordFileByte[]
SelectedRecordsString  
SelectedTemplateEntityReference  
UploadDocument   ContentByte[]None 
OverwriteExistingBoolean  
EntityEntity  
ParentEntityReferenceEntityReference  

First, let's create some extension methods that will help us call these undocumented commands to generate either a Word or an Excel document.

if (typeof BGuidinger == "undefined") {
    BGuidinger = { __namespace: true };
}
if (typeof BGuidinger.Samples == "undefined") {
    BGuidinger.Samples = { __namespace: true };
}

BGuidinger.Samples.Sdk = {
    ExportWordDocument: function (templateId, entityType, entityId) {
        this.EntityTypeCode = entityType;
        this.SelectedRecords = "[ '{" + entityId + "}' ]";
        this.SelectedTemplate = {
            entityType: "documenttemplate",
            id: templateId
        };

        this.getMetadata = function () {
            return {
                operationName: "ExportWordDocument",
                operationType: 0,
                parameterTypes: {
                    "EntityTypeCode": {
                        "typeName": "Edm.Int32",
                        "structuralProperty": 1
                    },
                    "SelectedRecords": {
                        "typeName": "Edm.String",
                        "structuralProperty": 1
                    },
                    "SelectedTemplate": {
                        "typeName": "mscrm.documenttemplate",
                        "structuralProperty": 5
                    }
                }
            };
        };
    },
    UploadDocument: function (entityType, entityId, filename, content) {
        this.Content = content;
        this.OverwriteExisting = true;
        this.Entity = {
            entityType: 'sharepointdocument',
            id: '00000000-0000-0000-0000-000000000000',
            title: filename
        };
        this.ParentEntityReference = {
            entityType: entityType,
            id: entityId
        };

        this.getMetadata = function () {
            return {
                operationName: "UploadDocument",
                operationType: 0,
                parameterTypes: {
                    "Content": {
                        "typeName": "Edm.String",
                        "structuralProperty": 1
                    },
                    "OverwriteExisting": {
                        "typeName": "Edm.Boolean",
                        "structuralProperty": 1
                    },
                    "Entity": {
                        "typeName": "mscrm.sharepointdocument",
                        "structuralProperty": 5
                    },
                    "ParentEntityReference": {
                        "typeName": "mscrm.crmbaseentity",
                        "structuralProperty": 5
                    }
                }
            };
        };
    }
};

What's awesome about the UploadDocument action is we don't have to include a dependency on the SharePoint SDK (and deal with ILMerge...).  This is the same action Dynamics 365 uses when you upload a document through the UI (check the network trace when you upload a document).

 

Comments

KolomiicSew

http://bit.ly/37s3dPW - coursework help university
Need help with your Dissertation, Assignments or Essays?
No problem! Anything from a short essay to exam notes, editing or our full dissertation service.
http://bit.ly/2QkRwVw - custom thesis writing services


For partners http://bit.ly/2Qebt05

<a href=http://nukesports.com/products.php?product=yoga-leggings-tights-pants-Quality%252d14&tab=ProductReviews>Professional essay writers for hire</a> <a href=http://gupta-inconsistent-harder.catlink.eu/general-discussion/848277212/write-my-statistics-paper>write my statistics paper</a> <a href=http://sulutonline.com/opini/1741-berangus-mafia-tanah.html?page=327#comment-2466581>what should i write my paper about</a> 816f1a4

KolomiicSew

BukaloSew

http://bit.ly/35eCYuX - write my paper for me in 3 hours
We bring you the evolution of quality and the revolution of satisfaction.
Here, you can order anonymously an academic paper written from scratch. You can also request professional editing. Or go for proofreading. It’s really your call. And the prices… They are beyond sweet!
OUR QUALITY & SERVICES EVOLVE, BUT OUR PRICES STAY AFFORDABLE
http://bit.ly/2QkRwVw - uk thesis


For partners http://bit.ly/2Qebt05

<a href=http://snacks-resumed-spreads.catlink.eu/general-discussion/849232095/auto-paraphrasing>Auto paraphrasing</a> <a href=http://standpoint-ativan-outs.catlink.eu/general-discussion/849295903/cheap-essay-writer-service>Cheap essay writer service</a> <a href=http://www.tevilar.com/?p=1197&cpage=1#comment-60709>Custom handwriting paper</a> 936e279

BukaloSew

VarennikovSew

http://bit.ly/2tpE9u7 - professional writing company
Staring at a blank screen and frantically gulping coffee won’t materialize an admissions essay.
The solution? Use this college admission essay writing service! Hiring a professional, rather than fumbling the task yourself, lets you drastically improve your chances of admission.
Our writing service allows you to obtain a custom admissions essay quickly, easily, and affordably.
The experts we hire obsess over every aspect of their writing, thereby ensuring that our customers have the highest probability of being accepted to college.
We are looking forward to making a difference in your academic life.
http://bit.ly/2tpE9u7 - speech writing services online


For partners http://bit.ly/2Qebt05

<a href=http://machining-buick-hero.catlink.eu/general-discussion/854996100/seo-content-writing-services>Seo content writing services</a> <a href=http://logged-europa-attained.catlink.eu/general-discussion/854710167/custom-essay-company>Custom essay company</a> <a href=http://causes-icons-pax.catlink.eu/general-discussion/854813384/help-me-write-an-essay>Help me write an essay</a> 097816f

VarennikovSew

GoncharovSew

http://bit.ly/35eCYuX - coursework on a resume Staring at a blank screen and frantically gulping coffee won’t materialize an admissions essay. The solution? Use this college admission essay writing service! Hiring a professional, rather than fumbling the task yourself, lets you drastically improve your chances of admission. Our writing service allows you to obtain a custom admissions essay quickly, easily, and affordably. The experts we hire obsess over every aspect of their writing, thereby ensuring that our customers have the highest probability of being accepted to college. We are looking forward to making a difference in your academic life. http://bit.ly/37s3dPW - custom papers writing For partners http://bit.ly/2Qebt05 <a href=https://freebak.com/tuijian/isaoquan.html/comment-page-453#comment-108200>Writing my dissertation</a> <a href=https://www.frannexus.com/?tfa_next=/forms/view/4723431/674421f1c65f81c7f1373cc8e2c59822/155329774&sid=54418ec431f87c71fc4b1cb03c850b14>Creative writing help</a> <a href=http://h8twsnkw6058cnhkcs515rszhmqpa9eq.catlink.eu/general-discussion/868262596/rhmgugxsqcdriv?page=1#post-886337776>Essays on the movie the help</a> 783_94d New iPhone 11 http://trk.adtrk15.com/SHki New iPhone 11

GoncharovSew

PljusninSew

http://bit.ly/35eCYuX - phd dissertations
Staring at a blank screen and frantically gulping coffee won’t materialize an admissions essay.
The solution? Use this college admission essay writing service! Hiring a professional, rather than fumbling the task yourself, lets you drastically improve your chances of admission.
Our writing service allows you to obtain a custom admissions essay quickly, easily, and affordably.
The experts we hire obsess over every aspect of their writing, thereby ensuring that our customers have the highest probability of being accepted to college.
We are looking forward to making a difference in your academic life.
http://bit.ly/2tpE9u7 - who can write my paper


For partners http://bit.ly/2Qebt05

<a href=https://yorgunfm.net/%C5%9Fark%C4%B1lar/deniz-seki-adaletsiz-secim/#comment-783>Cheap essay service</a> <a href=http://wetacanada.com/hello-world/#comment-198>Help me write a thesis statement</a> <a href=http://www.hopejeffcoat.com/?page_id=59#comment-769770>Essay help</a> 816f1a4

New iPhone 11 http://trk.adtrk15.com/SHki New iPhone 11

PljusninSew

GorbushovSew

XRumer...
In addition, XRumer bypasses text protection against robots - questions like “How much will 2 + 2?”, “Name the capital of Russia”, etc.
The program knows more than 170,000 answers to such questions, all arithmetic is automatically calculated, and the knowledge base is updated monthly.
A set of unique technologies allows you to achieve very good and interesting results.
High-tech functions such as the Antispam thematic distribution system (a message is sent to each forum in accordance with the topics of this forum, regardless of language and region), the Question-Answer system and others - distinguish XRumer from other similar complexes, creating opportunities for real Smart and even socially useful mailing.
For Xrumer Acquisition Issues - http://bit.ly/2KDtGl7

Captcha recognition / automatic captcha input
Surely almost everyone came across an inscription when registering on any site: "Enter the number you see" and a distorted picture. This CAPTCHA (CAPTCHA, pictocode, ticket) is a graphic protection designed to distinguish between people and programs.
For Xrumer Acquisition Issues - http://bit.ly/2lgBzxz

<a href=http://www.sommarhus.nu/9/comment-page-1/#comment-51476>automatic captcha recognition</a> <a href=http://rybolovnyj-magazin.ru/blog/mikrodzhigovaya-lovlya-na-rekah-i-vodohranilischah#comment_166797>XRumer</a> <a href=http://guestbook.ent-moreira.izihost.com/index.php?&mots_search=&lang=francais&skin=&&seeMess=1&seeNotes=1&seeAdd=0&code_erreur=Zp7EoCIZRw>XRumer</a> 36e2799

GorbushovSew

Robertknike

http://bit.ly/30jI5Z6 - Urgently need a friend
http://bit.ly/2PW5ZH3 - Dating

http://bit.ly/2vBTcCL - health products
http://bit.ly/2KlgMqG - Adult Video Chat
http://bit.ly/3aGPqXD - Wheel of fortune
http://bit.ly/2VTRas9 - dating
http://bit.ly/3cJdafe - super prize draw
http://bit.ly/3cAQVIB - dating

Robertknike

DennisCot

http://bit.ly/39RLXW2 The easiest way to earn Bitcoins? Just change your browser to CryptoTab and receive payments to your balance every 10 minutes. You will get BTC for simply using it, even if just having CryptoTab browser window open. It takes less than 1 minute to start earning - http://bit.ly/38Wex7z

DennisCot

DennisCot

http://bit.ly/39RLXW2 It’s already a month as I’ve been using new browser. CryptoTab browser, to be exact. Do you want me to ask why? I’ll tell you. It doesn’t just browse well, but allows you to earn Bitcoin with ease! Learn more, follow the link - http://bit.ly/38Wex7z

DennisCot

DennisCot

http://bit.ly/39RLXW2 Friends, let me share with you a cool browser with built-in mining features, I've been using it few weeks now and results are great! You get paid in Bitcoins and payments come directly to your Bitcoin wallet. Download it here - http://bit.ly/38Wex7z

DennisCot

Brantrix

Hello! I like your site and uncontested communication. Thank. I desire be overpowering my thoughts here.

<a href=http://www.3ec0f4c78de5021b18.com>www.3ec0f4c78de5021b18.com</a>

Brantrix

BezgodovSew

http://bit.ly/2tpE9u7 - research paper services cheap College Admission Essay Writing Service –
Your New Secret Weapon
http://bit.ly/2tpE9u7 - need help with essay writing


For partners http://bit.ly/2Qebt05

[url=http://keinlebenohnekunst.de/node/4?page=13884#comment-694292]Research methodology dissertation[/url] [url=http://vmestecard-reg.ru/#comment-1220]Buy a literature review paper[/url] [url=http://jsshbx.com/english/lyb.asp]Academic writers online[/url] f1a4bdb

BezgodovSew

Victorvaw

best place to buy Voveran SR in Ireland saturday delivery

[b] WE DELIVER WORLDWIDE! CLICK HERE >>> [/b] https://bit.ly/2wAThqD

[url=http://totalworldstore.com/shop/go.php?sid=5&search=Voveran SR] [u][b]>>> WE DELIVER WORLDWIDE! CLICK HERE <<<[/b][/u] [/url]


TAGS:

licensed pharmacy Voveran SR in Australia
cheap buying online Voveran SR tablets without script USA
order cheap generic Voveran SR without dr prescription
where do i get Voveran SR USA no prescription needed
Voveran SR delivered overnight USA
legitimate places to buy Voveran SR without prescription mexico
Voveran SR prescription online
buy online Voveran SR without a prescription
Voveran SR no prescription
cheap Voveran SR online in
Voveran SR next day delivery
RELATED SEARCHES:
http://ctetonline.com/new-norms-given-by-ncte-in-december-2014-for-b-ed-admission-requirements-from-the-session-2015-onwards-2/?unapproved=191458&moderation-hash=8e17ee08b5753794f6f985f23605abd5#comment-191458 http://www.soccer-manager.eu/forum/index.php?topic=136768.new#new https://stakeadvisor.com/boards/topic/where-can-i-order-cheapest-robaxin-500-mg-just-0-73-per-pill-with-visa-or-mastercard-robaxin-methocarbamol-in-usa/ http://agoristchef.com/2017/02/27/hello-world/?unapproved=56184&moderation-hash=c09560e17b35928e25aa7b32ac77798c#comment-56184 http://dreitv.de/2016/05/13/rassismus-macht-einsam-und-das-ist-auch-gut/?unapproved=41899&moderation-hash=c96f199bb76155f511410e1d9939dab4#comment-41899 http://skzebetin.almadeo.cz/forum/ http://startup-forum.net/viewtopic.php?f=44&t=342739&p=208394#p208394 http://kaylaangstadt.com/cows-head-for-dinner/?unapproved=87474&moderation-hash=7c0f136bb643b9d22515d36413da9394#comment-87474 https://uc.infinix.club/forum.php?mod=viewthread&tid=2658466&extra=

Victorvaw

Victorvaw

order at low price Sildenafil/Duloxetine in UK tablet without script

[b] WE DELIVER WORLDWIDE! CLICK HERE >>> [/b] https://bit.ly/usamedsonline

[url=http://totalworldstore.com/shop/go.php?sid=5&search=Sildenafil/Duloxetine] [u][b]>>> Want to buy with Discount? CLICK HERE! <<<[/b][/u] [/url]


TAGS:

best price for generic Sildenafil/Duloxetine in Australia
best price Sildenafil/Duloxetine no prescription quick delivery USA
generic Sildenafil/Duloxetine without a prescription or membership
purchase online Sildenafil/Duloxetine without credit card or check
Sildenafil/Duloxetine generic fedex no prescription
discount Sildenafil/Duloxetine generic fedex no prescription
Sildenafil/Duloxetine no script needed USA
orders Sildenafil/Duloxetine without a prescription
Sildenafil/Duloxetine online in
cheap buying online Sildenafil/Duloxetine without a prescription USA
Sildenafil/Duloxetine without a rx overnight delivery
RELATED SEARCHES:
http://admin.infinix.club/forum.php?mod=viewthread&tid=2957465&pid=11857572&page=3&extra=#pid11857572 http://ashemale.live/will-i-qualify-for-medical-insurance/?unapproved=4152&moderation-hash=cdf0fc0fef12c33fee186b84b71d21b3#comment-4152 https://healthy.watch/forum/showthread.php?tid=308058 http://optimed24.waw.pl/forum/viewtopic.php?f=7&t=308365&p=375106#p375106 http://bodhisarango.com/seminar-topics/?unapproved=1014529&moderation-hash=415c500248375e530f708ae682bde7c7#comment-1014529 http://totalkarnage.net/phpBB2/viewtopic.php?f=23&t=6483&p=261296#p261296 http://cs-hlds.ru/forum/17-5587-3#56990 https://www.dartmoorzoo.org.uk/responding-to-covid-19/?unapproved=12461&moderation-hash=23947789493a1918f257b71a0ca26772#comment-12461 https://www.omranelmafzar.ir/forums/topic/lanoxin-pharmacie-en-ligne-en-angers-lanoxin-pharmacie-en-ligne-sans-ordonnance/ http://uc.infinix.club/forum.php?mod=viewthread&tid=2958549&pid=11859867&page=3&extra=#pid11859867 https://foros.aymon.es/viewtopic.php?f=4&t=9174 https://yuli10.com/forums/topic/maxaquin-moins-cher-maxaquin-pharmacie-en-italybon-prix https://scanurl.net/u/sai-detstwo-com-forum-index-php-topic-2645-0-wap2-html http://www.a-music.ru/blog/yamaha-hs-seria#comment_39745 http://www.arcieridellanotte.it/forum/viewtopic.php?f=2&t=438642&p=522648#p522648 http://skzebetin.almadeo.cz/forum/ http://driftergaming.org/showthread.php?tid=61513&pid=207823#pid207823 http://www.ctfportugal.pt/viewtopic.php?f=14&t=244314&p=449406#p449406 https://eamped.com/5-things-you-should-do-before-hiring-company-contractors/?unapproved=1872&moderation-hash=13437228c63e013c96fe1828e86cc641#comment-1872 http://moto-rage.com.ua/site/forum.php?mod=viewthread&tid=70&pid=159623&page=2802&extra=page%3D1#pid159623 https://wetraindonmuang.com/2020/03/26/hello-world/?unapproved=44&moderation-hash=bb77974997c0d2f686c20bad5212029d#comment-44 http://egz-fazt.ru/communication/forum/index.php?PAGE_NAME=message&FID=4&TID=59623&MID=165986&result=reply#message165986 http://kalamazooklub.com/?unapproved=293735&moderation-hash=2edf16d02b9fb4963952eb8e3d423c15#comment-293735 http://balancinglifeslemons.com/2019/04/what-brings-me-joy/?unapproved=233064&moderation-hash=36485ea0b510b90ff6338788d21b5275#comment-233064 http://www.doripesco.ro/forum/viewtopic.php?f=1&t=53&p=104129#p104129 http://www.e-zabava.net/videa/reklamy/147-virgin-cola-povedena-reklama/#comments http://cs-hlds.ru/forum/58-8561-1#57298 http://www.soccer-manager.eu/forum/index.php?topic=137587.new#new http://moto-rage.com.ua/site/forum.php?mod=viewthread&tid=339&pid=159450&page=1774&extra=page%3D1#pid159450 http://www.crablonia.de/viewtopic.php?f=8&t=146942&p=150003#p150003 http://homosexualita.eu/articles/papilomaviry-hpv-u-homosexualu/1769/ http://kapsulfilm.com/forum-tan-t-mlar-/114977-zyloprim-acheter-zyloprim-sans-ordonnance-gratuit-comprime.html#post171280 http://lifedagestan.ru/forum/12-1784-1#28203 http://easyconvo.com/talk/threads/%D0%B4%D0%BE%D0%B1%D0%B0%D0%B2%D0%B8%D1%82%D1%8C-%D0%BF%D1%80%D0%B8%D0%BD%D1%86%D0%B8%D0%BF-%D1%80%D0%B0%D0%B1%D0%BE%D1%82%D1%8B-%D0%B8%D0%BD%D1%82%D0%B5%D1%80%D0%BD%D0%B5%D1%82-%D0%BA%D0%B0%D0%B7%D0%B8%D0%BD%D0%BE.181688/page-6514#post-431450 https://argyle-phoenix.fr/index.php/component/kunena/welcome-mat/3667-allopurinol-pharmacie-en-ligne-en-belgique-allopurinol-en-ligne-en-saint-etienne http://www.ctfportugal.pt/viewtopic.php?f=14&t=244314&p=449341#p449341

Victorvaw

Victorvaw

buying at lowest price Celecoxib in Ireland saturday delivery

[b] QUALITY PILLS HERE! >>> [/b] http://bit.ly/us-meds

[url=http://totalworldstore.com/shop/go.php?sid=5&search=Celecoxib] [u][b]>>> VISIT OUR DISCOUNT PHARMACY <<<[/b][/u] [/url]


TAGS:

how to order Celecoxib in UK/GB
order online Celecoxib in australia without prescription
purchase at best price Celecoxib available united states
order generic Celecoxib shipped with no prescription USA
Celecoxib with overnight delivery
order easy Celecoxib nextday shipping
Celecoxib no script next day delivery USA
for sale Celecoxib medication without prescription
Celecoxib no rx in USA
buy easy legally Celecoxib overnight delivery
Celecoxib next day delivery USA
RELATED SEARCHES:
http://kuku28.com/forum.php?mod=viewthread&tid=2550&pid=7655575&page=37&extra=page%3D1#pid7655575 http://www.egregorphoto.com/livre-d-or/ https://telldiary.com/forum/?unapproved=150586&moderation-hash=51d44623c704577756694d955a2982a9#comment-150586 http://www.svar-tech.cz/elektroda-ph-58-o3-2mm-bazicka-etc http://letspedia.com/finally-get-realistic-finding-funding-business-2/?unapproved=68619&moderation-hash=98a02b3cddae75f19c7c7ba24d5c6f85#comment-68619 http://www.vmalumni.com/forums/topic/cytoxan-en-ligne-en-strasbourg-cytoxan-en-ligne-en-rouen/ http://fsfu.org.ua/forum/viewtopic.php?f=4&t=100529 https://forum.taskforcehusky.co.uk/thread-97306.html https://forum.blocksplode.com/showthread.php?tid=748072 https://rused.ru/irk-mdou53/forums/topic/omnicef-en-ligne-en-sion-bon-marche-omnicef-combien-ca-coute/

Victorvaw