locked
Add button to create related entity record RRS feed

  • Question

  • Hello , 

    I have created a related an entity that is related to opportunity ( relation between opportunity and "custom entity " is 1:N)

    I would like to add a button on the opportunity ribbon that will open the form of the related entity in order to create a new record . 

    I know how to put the button on the ribbon but i don;t find the function that i need to put behind . 

    I belive that i need to create e URL and then to put some parameters ...

    Can you help me ?

    Wednesday, August 20, 2014 2:26 PM

All replies

  • According to me, you can create a new dialog and after you can link this dialog to the ribbon.

    What do you think?

    Bye

    Alessandro


    Alessandro Graps

    Thursday, August 21, 2014 10:22 AM
  • I would like to put a JS function behind. 

     

    function addpl(ChildEntityTypeCode,FirstPrimaryItemId,PrimaryEntityTypeCode,ChildEntityTypeCode){

    ChildEntityTypeCode = "10038";
    PrimaryEntityTypeCode = "3";

    var url = Xrm.Page.context.getServerUrl()+
    "/main.aspx?etc= “ + ChildEntityTypeCode + ”&extraqs=%3f_CreateFromId%3d%257b3438E8FC-6428-E411-80E0-005056A03455%257d%26_CreateFromType%3d3%26etc%3d“+ ChildEntityTypeName +” &pagetype=entityrecord";
    window.open(url);

    }

    i am trying to use this one but is still not working ..

    Maybe you can help me . 

    Thursday, August 21, 2014 10:27 AM
  • try this one

    var url = Xrm.Page.context.getServerUrl()+"main.aspx?etn= “+Child entity schemaname+” &extraqs=%3f_CreateFromId%3d"+ parentRecordId +"%26_CreateFromType%3d”+Parent Entity type code +”%26etn%“+Child entity schemaname+” &pagetype=entityrecord";


    In your case:

    var url = Xrm.Page.context.getServerUrl()+
    "/main.aspx?etn= “ + ChildEntityTypeCode + ”&extraqs=%3f_CreateFromId%3d%257b3438E8FC-6428-E411-80E0-005056A03455%257d%26_CreateFromType%3dCODEMISSING%26etn%3d“+ ChildEntityTypeName +” &pagetype=entityrecord";
    window.open(url);
    }

    Is etn no etc...

    Bye

    Al.



    Alessandro Graps

    Thursday, August 21, 2014 11:09 AM
  • Ok , let s make it a little bit clear for me . 

    This is what i suppose to obtain : https://auth.msd2.sofrecom.fr/MSDELOB/main.aspx?etc=10038&extraqs=%3f_CreateFromId%3d%257b1E6383CD-2129-E411-80E0-005056A03455%257d%26_CreateFromType%3d3%26etc%3d10038%26preloadcache%3d1408623412302&histKey=63353098&newWindow=true&pagetype=entityrecord#131701233

    This is what i am obtaining : https://auth.msd2.sofrecom.fr/MSDELOB/main.aspx?etc=10038&extraqs=%3f_CreateFromId%3d%257b3438E8FC-6428-E411-80E0-005056A03455%257d%26_CreateFromType%3d3%26etc%3d10038&{1E6383CD-2129-E411-80E0-005056A03455}&pagetype=entityrecord    FROM THE FALLOWING CODE : 

    var url = Xrm.Page.context.getServerUrl()+"/main.aspx?etc=10038&extraqs=%3f_CreateFromId%3d%257b3438E8FC-6428-E411-80E0-005056A03455%257d%26_CreateFromType%3d3%26etc%3d10038&"+ FirstPrimaryItemId +"&pagetype=entityrecord";
    window.open(url);

    In the code Written by you : var url = Xrm.Page.context.getServerUrl()+
    "/main.aspx?etn= “ + ChildEntityTypeCode + ”&extraqs=%3f_CreateFromId%3d%257b3438E8FC-6428-E411-80E0-005056A03455%257d%26_CreateFromType%3dCODEMISSING%26etn%3d“+ ChildEntityTypeName +” &pagetype=entityrecord";
    window.open(url);

    What parameters should i put in Ribbon Workbench and what will be the order ?

    Thursday, August 21, 2014 12:22 PM
  • Solved with the fallowing function : 

    function addpl(){
    var GUIDvalue = Xrm.Page.data.entity.getId();
    var guidstring = GUIDvalue;
    var sliceguid = guidstring.slice(1,-1);
    var Childentityschemaname = "elob_pl";
    var parentRecordId = "1E6383CD-2129-E411-80E0-005056A03455";
    var ParentEntitytypecode = "3";
    var url = Xrm.Page.context.getServerUrl()+"/main.aspx?etn=" + Childentityschemaname + "&extraqs=%3f_CreateFromId%3d%257b"+ sliceguid +"%257d%26_CreateFromType%3d" +ParentEntitytypecode + "%26etn" + Childentityschemaname + "&pagetype=entityrecord";
    window.open(url);
    }

    Friday, August 22, 2014 11:43 AM
  • Hi,

    good solution! :-)

    Bye

    Alessandro


    Alessandro Graps

    Thursday, August 28, 2014 8:20 AM
  • You can also simply use Xrm.Utility , Check this

    Our Website| Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Thursday, August 28, 2014 10:35 AM
    Moderator