locked
need an idea regarding Custom html page... RRS feed

  • Question

  • Hi all,

    I have to develop a custom html page. Inwhich there will be a button, onclick of that I want to open New Account form. I have done till this.

    What I want is, if the user save and close that Account form the html page has to be refreshed....

    refreshing is ok, but how to know whether the account form got saved or not??

    any ideas??

    Thanks in advance..

    Wednesday, December 19, 2012 7:55 AM

Answers

  • Hi,

    I'm guessing you'd need something like:

    In your parent form button function:

    // Call the following from your parent form button
    function newAccount() {
        Xrm.Utility.openEntityForm('account', null, null);
    }
    
    function newAccountCallBack()
    {
        // Do what you need to do - remember that it will take some time for the account to be sent to the server and saved to the database
        alert('Refresh!');
    }
    

    Then add the following to your on save event on your Account form:

    function accountOnSave() {
        // Check if this is a Create Form
        if (Xrm.Page.ui.getFormType() == 1) {
            // If opened from the parent form, then call the callback function
            var parentOpener = window.top.opener;
            if (parentOpener!=null)
            {
            if (typeof(parentOpener.newAccountcallBack) !== 'undefined') {
                parentOpener.newAccountCallBack();
            }
            }
        }
    }

    Scott


    Scott Durow
    Read my blog: www.develop1.net/public     Follow Me on Twitter
    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"


    Thursday, December 20, 2012 9:59 AM
    Answerer

All replies

  • you can utilize save event arguments or You could set some flag in account entity on save and check this flag in your html page.

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

    Wednesday, December 19, 2012 8:14 AM
    Moderator
  • You might also try adding a call back function in your html page, then calling it using the following in the onsave event.

    window.top.opener.parent.onSavedCallback()
    Scott

    Scott Durow
    Read my blog: www.develop1.net/public     Follow Me on Twitter
    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Wednesday, December 19, 2012 8:43 AM
    Answerer
  • hi all,

    Thanks for replying...

    I resolved the problem...in the html button onclick the following jscript will run,

    function opennewwindow()

    {

    url=....;

    var textname = window.showModalDialog(url, '', 'dialogHeight=600px; dialogWidth=1000px; scroll=0; status=yes; resizable=yes; maximize:yes; minimize:yes;');
            if (textname == "done")
                refreshhtmlpage();

    }

    in the account form onsave event,

    function returnfunction()
    {
    window.returnValue="done";
    var isDirty = Xrm.Page.data.entity.getIsDirty();
    if(isDirty)
    window.returnValue="done";
    }

    Its working fine....but the account form is blinking whenever I click inside the form....any ideas....

    Wednesday, December 19, 2012 12:40 PM
  • Hi,

    I don't think that showing a CRM form in a modal dialog is a good idea - there is a lot of Javascript that might stop working correctly. You might be seeing the blinking because the form is trying to perform and operation that is being blocked by the modal dialog.

    If you use the call back approach, you wouldn't have this issue.

    Scott


    Scott Durow
    Read my blog: www.develop1.net/public     Follow Me on Twitter
    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Wednesday, December 19, 2012 9:29 PM
    Answerer
  • hi scott,

    can you explain the call back approach??

    how to open the crm form from html page and how to trigger the refreshing function in the html page if the crm form got saved or updated??

    Thursday, December 20, 2012 5:34 AM
  • Hi,

    I'm guessing you'd need something like:

    In your parent form button function:

    // Call the following from your parent form button
    function newAccount() {
        Xrm.Utility.openEntityForm('account', null, null);
    }
    
    function newAccountCallBack()
    {
        // Do what you need to do - remember that it will take some time for the account to be sent to the server and saved to the database
        alert('Refresh!');
    }
    

    Then add the following to your on save event on your Account form:

    function accountOnSave() {
        // Check if this is a Create Form
        if (Xrm.Page.ui.getFormType() == 1) {
            // If opened from the parent form, then call the callback function
            var parentOpener = window.top.opener;
            if (parentOpener!=null)
            {
            if (typeof(parentOpener.newAccountcallBack) !== 'undefined') {
                parentOpener.newAccountCallBack();
            }
            }
        }
    }

    Scott


    Scott Durow
    Read my blog: www.develop1.net/public     Follow Me on Twitter
    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"


    Thursday, December 20, 2012 9:59 AM
    Answerer
  • hi scott,

    thanks a lot man...info regarding 'Xrm.Utility.openEntityForm('account', null, null);' is really nice.

    Friday, December 21, 2012 6:01 AM