Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

email_activity_parties and activityParties

Posted on by Microsoft Employee

Hello, I'm trying to add an attachment to an activity party 

Here is the code: 

....email.email_activity_parties = activityParties;....

function CreateEmailAttachment() {
//get reporting session and use the params to convert a report in PDF

var params = getReportingSession();
//Email attachment parameters

var activitymimeattachment = Object();
activitymimeattachment.ObjectId = Object();
activitymimeattachment.ObjectId.LogicalName = "email";


activitymimeattachment.ObjectId = email.activitypartyid;

activitymimeattachment.ObjectTypeCode = "email",
activitymimeattachment.Subject = "File Attachment";

activitymimeattachment.FileName = "Commande.pdf";
activitymimeattachment.MimeType = "application/pdf";

encodePdf(params, activitymimeattachment);

//Attachment call

}

But I cannot retrieve the id of the activity party to join my attachment.

This is undefined : activitymimeattachment.ObjectId = email.activitypartyid;

Any ideas?

Thx in advance for your help

*This post is locked for comments

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: email_activity_parties and activityParties

    I just forgot to put the regarding so I added this when I'm creating the email:

    email.RegardingObjectId = {

                       Id: Xrm.Page.data.entity.getId(),    //Get the current entity Id , here OrderId

                       LogicalName: Xrm.Page.data.entity.getEntityName()//Get the current entity name, here it will be "salesOrder"

                   };

    thx all

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: email_activity_parties and activityParties

    I am in JS,  should I use the createEntityReference method ?

    thx

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: email_activity_parties and activityParties

    Here is my code :

    function CreateEmail()
    {

    debugger;

    try {

    email.Subject = "Bon de commande PDF";


    var activityParties = new Array();

    var partyObj0 = new Object();
    partyObj0.PartyId = { Id: ownerID, LogicalName: "systemuser" };
    partyObj0.ParticipationTypeMask = { Value: 1 };
    activityParties[0] = partyObj0;

    var partyObj1 = new Object();
    partyObj1.PartyId = { Id: ownerID, LogicalName: "systemuser" };
    partyObj1.ParticipationTypeMask = { Value: 2 };
    activityParties[1] = partyObj1;

    var partyObj2 = new Object();
    partyObj2.PartyId = { Id: ownerID, LogicalName: "systemuser" };
    partyObj2.ParticipationTypeMask = { Value: 2 };
    activityParties[2] = partyObj2;



    //set .email_activity_parties to activityParties
    email.email_activity_parties = activityParties;



    SDK.JScriptRESTDataOperations.Create(email, "Email", EmailCallBack, function (error) { alert(error.message); });


    }

    catch (e) {

    }
    finally
    {

    }

    }

  • Aileen Gusni Profile Picture
    Aileen Gusni 44,522 on at
    RE: email_activity_parties and activityParties

    Hi Jcharlot,

    The Object Id should be email Id iteslf if you use this Email as the object ype:

    activitymimeattachment.ObjectId.LogicalName = "email";

    , not the email.activitypartyid

    See sample here:

    msdn.microsoft.com/.../gg328344.aspx

    ActivityMimeAttachment _sampleAttachment = new ActivityMimeAttachment

                           {

                               ObjectId = new EntityReference(Email.EntityLogicalName, _emailId),

                               ObjectTypeCode = Email.EntityLogicalName,

                               Subject = String.Format("Sample Attachment {0}", i),

                               Body = System.Convert.ToBase64String(

                                       new ASCIIEncoding().GetBytes("Example Attachment")),

                               FileName = String.Format("ExampleAttachment{0}.txt", i)

                           };

                           _emailAttachmentId[i] = _serviceProxy.Create(_sampleAttachment);

    Hope this helps.

    Thanks.

  • Bruno Lucas Profile Picture
    Bruno Lucas 5,421 on at
    RE: email_activity_parties and activityParties

    Hi,

    Can you share the code where you create the activity party?

    there is just this line

    "....email.email_activity_parties = activityParties;...."

    probably something is happening there and the activity party is not creating

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,214 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans