locked
Open new form in crm 2011 using javascript RRS feed

  • Question

  • Hello,

    I have a custom entity with two forms and has a relationship with contact entity ,
    What I'm trying to do is open a new custom entity from contact entity using javascript

    How to specify the form id (not the default form) in the url ??

    Thanks.


    Zarour

    Thursday, June 7, 2012 7:00 AM

Answers

All replies

  • Hi Zarour,

    I hope you are trying to open new entity form with your custom form, so first you need to get id of your custom form, you can refer http://community.dynamics.com/product/crm/crmtechnical/b/xrmavanade/archive/2011/06/10/crm-2011-form-navigation.aspx how to get id.

    once you have id you can open new entity form refer http://msdn.microsoft.com/en-us/library/gg328483.aspx.

    make sure to add extraqs parameter to set form id.

    let us know if you have any other question.


    Conatact Me
    Follow me on Twitter
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    • Proposed as answer by HIMBAPModerator Thursday, June 7, 2012 7:18 AM
    • Marked as answer by zarour Thursday, June 7, 2012 8:27 AM
    Thursday, June 7, 2012 7:17 AM
    Moderator
  • Thank you Mahender,

    I tried this way and it works but I couldn't find how to map fields between the contact and the custom entity ??

    lets say custom entity has a lookup of the contact , when I open the from using that url it opens correctly but the contact id is not filled ?

    should I make mapping using custom function on the onload event of the custom entity ??

    Thank you for your quick reply .


    Zarour

    Thursday, June 7, 2012 7:29 AM
  • Hi Zarour,

    you won't be able to utilize mapping when open new window thorugh javascript code, what you can do you can create a webresourc to get values of required fields, and pass it to your form to set valeus refer (http://msdn.microsoft.com/en-us/library/gg334375.aspx).


    Conatact Me
    Follow me on Twitter
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.


    • Edited by HIMBAPModerator Thursday, June 7, 2012 7:58 AM
    • Proposed as answer by HIMBAPModerator Thursday, June 7, 2012 7:58 AM
    • Marked as answer by zarour Thursday, June 7, 2012 8:27 AM
    Thursday, June 7, 2012 7:58 AM
    Moderator
  • Thank you it works now :)

    Zarour

    Thursday, June 7, 2012 8:27 AM
  • Thank you 

    but can I ask you another question.

    I have created an sms activity entity, there is problem in crm default mapping when I create a sms activity from contact form the recipient attribute ,which is type of partylist ,

    this attribute is not being mapped automatically although there is a partyid in the extraqs parameter ,it only fills the regarding attribute 

    but if you open a phone call, the recipient is filled as well as the regarding object ??

    Do you have any idea on how to solve this issue ??


    Zarour

    Thursday, June 7, 2012 8:35 AM
  • I'm afraid the custom activity entities will not work exactly the same behaviour as the system activities.

    You might have to control this at the OnLoad JavaScript of the SMS Activity Entity form by populating the value for "To" attribute with the value from Regarding attribute when Xrm.Page.ui.getFormType() == 1     // Create form

    • Marked as answer by zarour Thursday, June 7, 2012 7:43 PM
    Thursday, June 7, 2012 4:20 PM
  • Hi,

    Try below steps and check if you are able to replicate sytem behaviour

    Try to create sms entity record from contact (from associated view) copy URL from address bar,

    then try to use the same url for creating sms entity record from your ribbon button.

    make sure to replace _createformid with contact entity id

    _CreateFromId%3d%257b689C8B47-8B9D-E111-883B-1CC1DEEA2718%257d%26

    let me know


    Conatact Me
    Follow me on Twitter
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Thursday, June 7, 2012 5:27 PM
    Moderator