locked
OnSave Issue CRM 2011 RRS feed

  • Question

  • Dear Gent,

    I am using CRM 2011 and I am using the bellow code for Projects status and to follow it up.

    Actually, the issue I am facing is that when I create new Project and check all the options for Project status to get a percentage of Project completion and save then it will save normally BUT the Problem is that when I want to change or edit a current Project the issue persist.

    The issue is the result updated but the percentage remaining at the first value when we save for the first time.

    Please Help on this.

    Here is the code.

    function Form_onsave()
    {
     Xrm.Page.getAttribute("new_process").setSubmitMode("always");
    }

    function UpdateProcess(number) {
     var newValue = Xrm.Page.getAttribute("new_process").getValue() + number;
     Xrm.Page.getAttribute("new_process").setValue(newValue);
    }

    function new_pofsignoff_onchange()
    {
     if (Xrm.Page.getAttribute("new_pofsignoff").getValue() == 1) { UpdateProcess(5); } else { UpdateProcess(-5); }
    }

    function new_infraassesment_onchange()
    {
     if (Xrm.Page.getAttribute("new_infraassesment").getValue() == 1) { UpdateProcess(5); } else { UpdateProcess(-5); }
    }

    function new_projectplan_onchange()
    {
     if (Xrm.Page.getAttribute("new_projectplan").getValue() == 1) { UpdateProcess(5); } else { UpdateProcess(-5); }
    }

    function new_sitereadinessconfirmation_onchange()
    {
     if (Xrm.Page.getAttribute("new_sitereadinessconfirmation").getValue() == 1) { UpdateProcess(5); } else { UpdateProcess(-5); }
    }

    function new_implementation_onchange()
    {
     if (Xrm.Page.getAttribute("new_implementation").getValue() == 1) { UpdateProcess(40); } else { UpdateProcess(-40); }
    }

    function new_acceptancetest_onchange()
    {
     if (Xrm.Page.getAttribute("new_acceptancetest").getValue() == 1) { UpdateProcess(10); } else { UpdateProcess(-10); }
    }

    function new_documentationtraining_onchange()
    {
     if (Xrm.Page.getAttribute("new_documentationtraining").getValue() == 1) { UpdateProcess(00); } else { UpdateProcess(-20); }
    }

    function new_handoversignoff_onchange()
    {
     if (Xrm.Page.getAttribute("new_handoversignoff").getValue() == 1) { UpdateProcess(10); } else { UpdateProcess(-10); }
    }

    Thursday, August 1, 2013 2:15 PM

All replies

  • Hi,
    If the percentage is stored inside a read only field, so you need to set the submit mode to always also to this field:

    function Form_onsave()
    {
     Xrm.Page.getAttribute("new_process").setSubmitMode("always");
     Xrm.Page.getAttribute("new_percentage").setSubmitMode("always"); //assuming the field name is new_percentage
    }

    also you need to check if the function that calculate the percentage is called.

    another issue:
    in your code for new_documentationtraining you are substracting -20 but adding 0, I think you need to add 20, so the code will be:

    function new_documentationtraining_onchange()
    {
     if (Xrm.Page.getAttribute("new_documentationtraining").getValue() == 1) { UpdateProcess(20); } else { UpdateProcess(-20); }
    }


    My blog: www.crmanswers.net

    Thursday, August 1, 2013 2:44 PM
  • Dear Guido,

    Thank you for your replay.

    Actually, I have changed what you proposed above but the issue still the same.

    To Describe my issue in a better way I have attached a screen shot.

    Bellow you will find the different options for Project Progress:

    POF Sign off which will add 5% to the Project Status....etc until it get 100%.

    The Progress is Normal Here in this page and everything is going well.

    The Problem is, if this is an existing Record and the current Project Status is 30 and I add to the progress then I will see the new percentage correct but once I save the changes then it will return back to 30.

    Hope this will be more clear for you.

    Thursday, August 1, 2013 3:09 PM