Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Copy data from Word Template/document to create a case in CRM online (Dynamics 365)

Posted on by 255

I have a requirement where a plugin will trigger on recieving an email from a specific email address and will have an attachment i.e. abc.docx

I need to read abc.docx and get all attributes and convert into a case record in CRM

I can get file name and body of the document using following query 

   QueryExpression _attachmentQuery = new QueryExpression
            {
                EntityName = "activitymimeattachment",
                ColumnSet = new ColumnSet("activitymimeattachmentid","filename", "body"),
                Criteria = new FilterExpression
                {
                    Conditions =
                        {
                            new ConditionExpression
                            {
                                AttributeName = "objectid",
                                Operator = ConditionOperator.Equal,
                                Values = { emailid }
                            },
                            new ConditionExpression
                            {
                                AttributeName = "objecttypecode",
                                Operator = ConditionOperator.Equal,
                                Values = {"email"}
                            }
                        }
                }
            };

            EntityCollection results = service.RetrieveMultiple(
                _attachmentQuery);


            return results;


However when I am unable to pass this step as when I try to convert this to stream and/or use in WordprocessingDocument I get exception Null

Any idea if it is possible in CRM online?

I have  merged 'DocumentFormat.OpenXml' suing ILmerge but still no luck

Any help appreciated.

Thanks 

*This post is locked for comments

  • Suggested answer
    Abbas Khan Profile Picture
    Abbas Khan 255 on at
    RE: Copy data from Word Template/document to create a case in CRM online (Dynamics 365)

    Thanks Joman however my issue was not to fetch data back, issue was with the reading stream

    Finally I realised that document I was trying to read was .doc and not .docx

    Once I changed document to .docx it has started working.

  • Suggested answer
    joman Profile Picture
    joman 617 on at
    RE: Copy data from Word Template/document to create a case in CRM online (Dynamics 365)

    Good day.

    "objecttypecode" is an integer  value. "email" objecttypecode is 4202

    try to use

    Values = {4202}

    instead of

    Values = {"email"}

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans