web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Open a new form on click of a button

(0) ShareShare
ReportReport
Posted on by

Hello everyone!

I have a requirement where on the click of a button on the phone call form, a new form should open up. This new form is of Member.

Also the value of provider, which a look up must be passed on to the new form.

But i am not getting the desired result. if you could help me.

function OpenMemberCallNote()
{

alert("Opening Member Call note Form");


var parameters = {};
var callnote = Xrm.Page.getAttribute("pomco_callnote").getValue();
parameters["pomco_callnote"] = callnote;

var Provider = Xrm.Page.getAttribute("pomco_provider").getValue();
parameters["pomco_providerid"] = Provider[0].id;
parameters["pomco_provideridname"] = Provider[0].name;
parameters["pomco_provideridtype"] = Provider[0].entityType;


Xrm.Utility.openEntityForm("pomco_membercallnote",null,parameters);
}

I am only able to pass call note in the parameter. But as soon as I try to pass provider, it is throwing an error.

*This post is locked for comments

I have the same question (0)
  • BharatPremji Profile Picture
    2,485 on at

    Hi Darshani,

    What error are you getting?

    Could you not achieve this functionality using out of the box mapping?

    Bharat

  • Community Member Profile Picture
    on at

    I am not able to map this functionality using out of the box mapping because this is a custom button created.  The problem lies with the passing of lookup value as a parameter. As soon as i try doing that it throws an error. Else, the form opens. I am able to pass multi-line text as well. Only not able to pass lookup.

  • Suggested answer
    BharatPremji Profile Picture
    2,485 on at

    Hi Darshani,

    I managed to get it working for a lookup from the Invoice entity and opened the contact form by using this code:

    function openContactForm() {

       var parameters = {};

       parameters["jobtitle"] = "IT Manager";

       var customer = Xrm.Page.getAttribute("customerid").getValue();

       if (customer != null) {

           var customerId = customer[0].id;

           customerId = customerId.replace('{', '').replace('}', '');

           parameters["parentcustomerid"] = customerId;

           parameters["parentcustomeridname"] = customer[0].name;

           parameters["parentcustomeridtype"] = "account";

           Xrm.Utility.openEntityForm("contact", null, parameters, true);

       }

    }

    So the customerid field is from the Invoice record and the parentcustomerid field is on the contact record.

    From reading a few posts online I think you need to change your function to this:

    function OpenMemberCallNote() {

       alert("Opening Member Call note Form");

       var parameters = {};

       var callnote = Xrm.Page.getAttribute("pomco_callnote").getValue();

       parameters["pomco_callnote"] = callnote;

       var Provider = Xrm.Page.getAttribute("pomco_provider").getValue();

       if (Provider != null) {

           var ProviderId = Provider[0].id;

           ProviderId = ProviderId.replace('{', '').replace('}', '');

           parameters["pomco_providerid"] = ProviderId;

           parameters["pomco_provideridname"] = Provider[0].name;

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

       }

    }

    The following line is not needed if the lookup is for a single entity:

    parameters["pomco_provideridtype"] = Provider[0].entityType;

    The reason I needed it in my function is that the parentcustomerid can be an Account or a Contact

    Hope that helps

    Bharat

  • Suggested answer
    TNS Profile Picture
    1,197 on at

    Hi...

        Try like this...

         //code written in phone call

    function OpenMemberCallNote()

    {

    alert("Opening Member Call note Form");

    var parameters = {};

    var callnote = Xrm.Page.getAttribute("pomco_callnote").getValue();

    parameters["pomco_callnote"] = callnote;

    var Provider = Xrm.Page.getAttribute("pomco_provider").getValue();

    parameters["pomco_providerid"] = Provider[0].id;

    parameters["pomco_provideridname"] = Provider[0].name;

    parameters["pomco_provideridtype"] = Provider[0].entityType;

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

    }

    //code to be written in member

    function tests()

    {

      var x= Xrm.Page.context.getQueryStringParameters();

      var t= new Array();

      t[0]= new Object();

      t[0].id=x["pomco_providerid"];

      t[0].name=x["pomco_provideridname"];

      t[0].entityType=x["pomco_provideridtype"];

      Xrm.Page.getAttribute("attribute name of lookup").setValue(t);

    }

  • Suggested answer
    Sayhaitokumar Profile Picture
    7,042 on at

    Hello Darshini,

    Read the below blog you may get some idea.

    ashwaniashwin.wordpress.com/.../xrm-utility-open-entity-forms-and-html-webresource-in-dynamics-crm-2011

  • Community Member Profile Picture
    on at

    Thanks for the reply, I tried doing this but still getting the same error!

  • Community Member Profile Picture
    on at

    Thanks for the reply, but still the error remains.

  • BharatPremji Profile Picture
    2,485 on at

    Hi,

    Can you confirm which fields are on your phone call entity and which are on the entity you are trying to open?

    Bharat

  • TNS Profile Picture
    1,197 on at

    Hi..

       The code you have given it's correct ...can you show the code which you have written on the second form(Member form) which you want to open.....

  • Community Member Profile Picture
    on at

    This is the code on the Phone Call entity:

    function OpenMemberCallNote()

    {

    alert("Opening Member Call note Form");

    var parameters = {};

    var callnote  = Xrm.Page.getAttribute("pomco_callnote").getValue();

    parameters["pomco_callnote"] = callnote;

    var Provider = Xrm.Page.getAttribute("pomco_provider").getValue();

    alert(Provider[0].id);

    alert(Provider[0].name);

    alert(Provider[0].entityType);

    parameters["pomco_provider"] = Provider[0].id;

    parameters["pomco_providername"] = Provider[0].name;

    parameters["pomco_providertype"] = Provider[0].entityType;

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

    }

    And this is the code on the member:

    function tests()

    {

     var x= Xrm.Page.context.getQueryStringParameters();

     var t= new Array();

     t[0]= new Object();

     t[0].id=x["pomco_provider"];

     t[0].name=x["pomco_providername"];

     t[0].entityType=x["pomco_providertype"];

     Xrm.Page.getAttribute("pomco_provider").setValue(t);

    }

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans