Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Attachment Entity

(0) ShareShare
ReportReport
Posted on by 850

Hi Guyz,

I have a requirement to implement.

On click of custom button i am opening attachment form. After uploading one document i am clicking on Attach button, and i am getting some error.

Can any one help me with this. My requirement is to user should be able to submit doc on click of custom button. Thank you for your help.

My code is:

function openAttachmentForm() {
debugger;
//var parameters = {};
//parameters["testid"] = Xrm.Page.data.entity.getId();
//parameters["new_name"] = Xrm.Page.getAttribute("new_name").getValue();
recordIDwithBraces = Xrm.Page.data.entity.getId();
var recordID = recordIDwithBraces.substring(1, 37);
Xrm.Utility.openEntityForm("activitymimeattachment", null, null);
}

Error I am getting is

File Could Not Be Uploaded

Invalid Argument.

Attribute: objectid cannot be set to NULL

*This post is locked for comments

  • naZir Profile Picture
    naZir 850 on at
    RE: Attachment Entity

    Hi Rawish,

    Thank you for the response. But that code doesn't work any more in dynamics 365 .. :(

  • Suggested answer
    Rawish Kumar Profile Picture
    Rawish Kumar 13,756 on at
    RE: Attachment Entity

    the problem is you are just opening the attachment form - but once attachment is added - it doesnt know where to go as we are not providing it the entity record id :

    you can follow the below post to take some reference from it untill some other expert doesnt give you exact code :

    http://himbap.com/blog/?p=2378

  • naZir Profile Picture
    naZir 850 on at
    RE: Attachment Entity

    function openAttachmentForm() {

       debugger;

       var recordIDwithBraces = Xrm.Page.data.entity.getId();

       var recordID = recordIDwithBraces.substring(1, 37);

       var testName = Xrm.Page.getAttribute("new_name").getValue();

       var parameters = {};

       parameters["objectid"] = recordID;

       parameters["objectidtype"] = "new_test";

       //parameters["testid"] = Xrm.Page.data.entity.getId();

       //parameters["new_name"] = Xrm.Page.getAttribute("new_name").getValue();

       Xrm.Utility.openEntityForm("activitymimeattachment", null, parameters);

       //Xrm.Page.entity.save();

    }

    This is my code. And It is Throwing Error. Not able to open the form.Tell me if i am missing any thing. Thank you

    Error

    An error has occurred. 

    Try this action again. If the problem continues, check the Microsoft Dynamics 365 Community for solutions or contact your organization's Microsoft Dynamics 365 Administrator. Finally, you can contact Microsoft Support.

  • Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: Attachment Entity

    Hi naZir,

    I am aware that you cannot customize the attachment entity.

    What I was suggesting is opening the attachment for using Xrm.Utility.openEntityForm or just passing a url with the parameters included in it.

    Try it out.

  • naZir Profile Picture
    naZir 850 on at
    RE: Attachment Entity

    Hi Aric,

    It wont work that way. Try to implement the scenario.

    When i am clicking the custom button, It is opening a new attachment form. But after uploading i am clicking attach button.. that time only the error is coming. We can not customize the attachement entity. Any way to implement the same scenario ... Thank you

  • Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: Attachment Entity

    Hi naZir,

    The objectid is an EntityReference that you need to pass which has the entity name and entity id where the attachment will belong to:

    note[“objectid”] = new EntityReference(“contact”, entityId);

    In JS:

    parameters["objectid"] = "2878282E-94D6-E111-9B1D-00155D9D700B";

    parameters["objectidtype"] = "contact";

    Try it out. Hope it works.

  • naZir Profile Picture
    naZir 850 on at
    RE: Attachment Entity

    But this about activities. Here i am trying with the attachment. This way it is not working. Can you post the code...

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Attachment Entity

    Hi Nazir,

    You are opening an empty attachment form and not relating it to anything.

    I think you need to pass the parameters out of which Objectid is one required parameters.

    Please refer to below link for passing parameters

    social.microsoft.com/.../passing-regardingobjectidtype-to-xrmutilityopenentityform

    Hope this helped.

    Thanks

    Phanidhar

  • naZir Profile Picture
    naZir 850 on at
    RE: Attachment Entity

    Thank you sir for reaching. I have added the code and error

  • naZir Profile Picture
    naZir 850 on at
    RE: Attachment Entity

    No, Its not about the doc extension related issue.

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