1

I have a document library with multiple content types of word templates.

In my event receiver I need to choose the right template based on a field of the modified/created list item.

Any ideas how to do that?

2
  • Is the event receiver running on items in the document library with the templates? Or is it running on items in a separate list? – Dylan Cristy Mar 12 '20 at 16:51
  • It is running in the document library with the templates – Yossi Alfia Mar 12 '20 at 17:07
1

I've managed to do that as below:

...
SPDocumentLibrary lib = (SPDocumentLibrary)web.Lists["listname"];
SPContentType contentType = lib.ContentTypes["content-type-name"];
...
SPFile spf = web.GetFile(contentType.DocumentTemplateUrl);
...

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.