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)

Error in service activity form

(0) ShareShare
ReportReport
Posted on by 165

Hello,

since some time I get this odd onload event error when selecting a service in the service activity form.

My error is in german but I'll try my best to translate it:

Error in the customized event of this field.

Field:serviceid

Event:onchange

Error: Can't obtain the attribute "SetParamter" of an undefined or null reference.

Auf deutsch:

Fehler im benutzerdefinierten Ereignis dieses Feldes.

Feld:serviceid

Ereignis:onchange

Fehler:Die Eigenschaft "SetParameter" eines undefinierten oder Nullverweises kann nicht abgerufen werden.

The version of CRM is CRM 2011 Rollup 11

We can't update any further at the moment because we're having some issues which have to be resolved first.

I hope someone can point me in the right direction.

Thank you in advanced.

*This post is locked for comments

I have the same question (0)
  • ScottDurow Profile Picture
    21 on at

    Hi,

    It looks like you have some custom JavaScript in your Service Field OnChange handler - this error is common with some unsupported code that changes the fetchxml on a subgrid which needs modification after a Update Rollup is applied.

    Could you post your OnChange javascript and we can help you out.

    hth,

    Scott

  • Fabian B. Profile Picture
    165 on at

    Hello and thank you for your answer,

    since I'm new to the whole CRM topic, I don't really now where to look for the onchange javascript. Could you maybe tell me where I can find it?

    Fabian

  • Suggested answer
    ScottDurow Profile Picture
    21 on at

    Hi,

    You'll need to read up on JavaScript Webresources and their use in Form Events - msdn.microsoft.com/.../gg328261.aspx

    To find the onchange code, you'll need to open the form editor - Customize Ribbon Tab ->Form->Click on the Service Field ->Change Properties->Events tab->Look at the functions being called 'Onchange' and find the code in the corresponding webresource.

    hth,

    Scott

  • Fabian B. Profile Picture
    165 on at

    Hello,

    ok, that's where I looked in the first place but the serviceid field doesn't appear to contain any customized event handlers at all. There's only the form library called ServiceAppointment_main_libraray.js which contains the following:

    function Form_onload()

    {

    LoadScript ("/ISV/IT/Js/serviceappointment/setLookups.js","1.0");

    LoadScript ("/ISV/IT/Js/serviceappointment/copyServiceappointment.js","1.0");

    LoadScript ("/ISV/IT/Js/serviceappointment/reactivateServiceappointment.js","1.0");

    LoadScript ("/ISV/IT/Js/serviceappointment/setResourcesFromServiceappointment.js","1.0");

    LoadScript ("/ISV/IT/Js/serviceappointment/hideAlldayeventFromServiceappointment.js","1.0");

    LoadScript ("/ISV/IT/Js/serviceappointment/SetServiceFromServiceAppointment.js","1.0");

    LoadScript ("/ISV/IT/Js/serviceappointment/StateCloseFromServiceappointment.js","1.0");

    SetResourcesFromServiceappointment();

    HideAlldayeventFromServiceappointment();

    HideStatecloseFromServiceappointment();

    }

    function Form_onsave()

    {

    //CheckSubsequent_serviceFromServiceappointment();

    //SetStateReasonOnIncidentFromServiceappointment();

    }

  • ScottDurow Profile Picture
    21 on at

    Hi,

    It looks like your system is heavily customised.

    If you have JavaScript debugging skills, you can use the F12 debugger in IE to find the code that is causing teh problem. If you don't have JavaScript debugging skills, I suggest getting in touch with the developer(s) who performed these customisations.

    hth,

    Scott

  • Fabian B. Profile Picture
    165 on at

    Hello,

    thank you for the tip. i just tried debugging and it seems like this is causing the problem:

    function ServiceLookupChanged(oEvent){

       var aoItems=crmForm.serviceid.Items();

       if(aoItems.length>=1){

           var columns=[];

           columns.type="string";

           columns[0]="duration";

           columns[1]="initialstatuscode";

           _oServiceRetrieveCommand.SetParameter("id",aoItems[0].id);  <-- In particular this line *

           _oServiceRetrieveCommand.SetParameter("columns",columns);

           _oServiceRetrieveCommand.Execute(HandleGetService)

       }

    *because the attribute "SetParamter" of a undefinied or null refernce can't be obtained.

    EDIT: This is from ServiceAppointment.js

     

    Is it possible to tell from this what is causing the problem and how to resolve it or do I have to search further?

    Thank you in advanced.

    Fabian

  • Suggested answer
    ScottDurow Profile Picture
    21 on at

    The problem is with _oServiceRetrieveCommand - can you find where this object is declared?

  • Verified answer
    Fabian B. Profile Picture
    165 on at

    Hello,

    thank you for your support, I was able to resolve my problem.

    I put the following function into the form library:

    function serviceid_onchange_handler(eventObj,eventArgs)

    {

    return false;

    }

    I don't know of any disadvatages of this solution but so far it works for me.

    EDIT: Please be aware of the fact, that this, as Scott already mentioned, only disables the functinality causing the problem. So it's not a full on solution.

  • ScottDurow Profile Picture
    21 on at

    It looks like you are simply removing the functionality that is causing the problem rather than fixing the original code - if this is ok and you didn't need the customisations that it provided then fantastic!

  • Agucha Profile Picture
    10 on at

    Hello everybody,

    I'm new in the forum, and I have the same problem. So in the service field, there isn't events handler, but there are some form libraries in use for this fields. The first Library is ServiceAppointment_main_library.js and the code is:

    /// <reference path="XrmPageTemplate.js"/>
    /// <reference path="general.js"/>

    function Form_onsave() {
    var the_url = window.opener.document.URL;
    var lead_slashes = the_url.indexOf("//");
    var domain_start = lead_slashes + 2;
    var without_resource = the_url.substring(domain_start, the_url.length);
    var next_slash = without_resource.indexOf("/");
    var final_domain = without_resource.substring(0, next_slash);

    var d = crmForm.all.scheduledstart.DataValue;
    //alert(datacrm.ToString('yyyy/mm/dd');
    //crmForm.all.customers.DataValue[0].id
    var s = d.getYear() + "-";
    s += (d.getMonth() + 1) + "-";
    s += d.getDate();

    window.showModalDialog('http://' + final_domain + '/findapp/findapp.aspx?cliente=' + crmForm.all.customers.DataValue[0].id + '&data=' + s
    , '', 'dialogHeight:300px;dialogWidth:600px;center:yes;resizable=yes');
    }

    function my_onLoad() {
    //ConvertToButton('new_bottonecommessa', 'Commessa','75 px', BottoneCommessa_Click,'Cerca Commessa');
    ConvertToButton('new_bottonesede', 'Sede', '50 px', BottoneSede_Click, 'Cerca Sede');
    }

    function BottoneCommessa_Click() {
    var nWidth = 800;
    var nHeight = 600;
    var nLeft;
    var nTop;

    var lookup = new Array();
    lookup = crmForm.all.customers.DataValue;
    var cust = (lookup == null) ? '' : lookup[0].id;
    var comm = (crmForm.all.new_codice_commessa.DataValue == null) ? '' : crmForm.all.new_codice_commessa.DataValue;

    nLeft = (window.screen.width - nWidth) / 2;
    nTop = (window.screen.height - nHeight) / 2;

    var win = window.open('/Rapportini/new_commessa_select.aspx?ID=' + cust + '&COD=' + comm, 'Commesse', 'top=' + nTop + ',left=' + nLeft + ',height=' + nHeight + ',width=' + nWidth + ',toolbar=no,directories=no,scrollbars=yes,status=no,resizable=yes,location=no'); win.focus();
    }

    function BottoneSede_Click() {
    var nWidth = 800;
    var nHeight = 600;
    var nLeft;
    var nTop;

    var lookup = new Array();
    lookup = crmForm.all.customers.DataValue;
    var cust = (lookup == null) ? '' : lookup[0].id;
    var sede = (crmForm.all.new_sede.DataValue == null) ? '' : crmForm.all.new_sede.DataValue;

    nLeft = (window.screen.width - nWidth) / 2;
    nTop = (window.screen.height - nHeight) / 2;

    var win = window.open('/Rapportini/new_sede_select.aspx?ID=' + cust + '&COD=' + sede, 'Sedi', 'top=' + nTop + ',left=' + nLeft + ',height=' + nHeight + ',width=' + nWidth + ',toolbar=no,directories=no,scrollbars=yes,status=no,resizable=yes,location=no'); win.focus();
    }

    function ConvertToButton(fieldname, buttontext, buttonwidth, clickevent, title) {

    //check if object exists; else return
    if (document.getElementById(fieldname) == null) {
    return;
    }


    functiontocall = clickevent;
    crmForm.all[fieldname].DataValue = buttontext;
    crmForm.all[fieldname].readOnly = true;
    crmForm.all[fieldname].style.borderRight = "#3366cc 1px solid";
    crmForm.all[fieldname].style.paddingRight = "5px";
    crmForm.all[fieldname].style.borderTop = "#3366cc 1px solid";
    crmForm.all[fieldname].style.paddingLeft = "5px";
    crmForm.all[fieldname].style.fontSize = "11px";
    crmForm.all[fieldname].style.backgroundImage = "url(/_imgs/btn_rest.gif)";
    crmForm.all[fieldname].style.borderLeft = "#3366cc 1px solid";
    crmForm.all[fieldname].style.width = buttonwidth;
    crmForm.all[fieldname].style.cursor = "pointer";
    crmForm.all[fieldname].style.lineHeight = "18px";
    crmForm.all[fieldname].style.borderBottom = "#3366cc 1px solid";
    crmForm.all[fieldname].style.backgroundRepeat = "repeat-x";
    crmForm.all[fieldname].style.fontFamily = "Tahoma";
    crmForm.all[fieldname].style.height = "20px";
    crmForm.all[fieldname].style.backgroundColor = "#cee7ff";
    crmForm.all[fieldname].style.textAlign = "center";
    crmForm.all[fieldname].style.overflow = "hidden";
    crmForm.all[fieldname].attachEvent("onmousedown", push_button);
    crmForm.all[fieldname].attachEvent("onmouseup", release_button);
    crmForm.all[fieldname].attachEvent("onclick", functiontocall);
    crmForm.all[fieldname].style.lineHeight = "14px";
    crmForm.all[fieldname + '_c'].style.visibility = 'hidden';
    crmForm.all[fieldname].title = title;
    window.focus();

    function push_button() {
    window.event.srcElement.style.borderWidth = "2px";
    window.event.srcElement.style.borderStyle = "groove ridge ridge groove";
    window.event.srcElement.style.borderColor = "#3366cc #4080f0 #4080f0 #3366cc";
    }

    function release_button() {
    window.event.srcElement.style.border = "1px solid #3366cc";
    }
    }

    function customers_onchange() {

    var AccountID = '';
    var attributes = Xrm.Page.data.entity.attributes.get();
    for (var i in attributes) {
    var attribute = attributes[i];
    if (attribute.getName() == 'customers') {
    var value = attribute.getValue();
    if (value != null) {
    for (var j = 0; j < value.length; j++) {
    AccountID = value[j].id;
    }
    }
    }
    }

    if (AccountID != '') {
    var strQuery = "accountSet?$select=address1_city&$filter=accountId eq guid'" + AccountID + "'";
    generaljs.runRESTQuery(strQuery,
    function (result) {
    for (var l = 0; l < result.d.results.length; l++) {
    Xrm.Page.getAttribute("location").setValue(result.d.results[l].address1_city);
    }

    },
    function (jqXHR, textStatus, err) {
    alert(textStatus);
    alert(err);
    });
    }
    }

    Can you find where is the the error?

    So, now I'm using a CRM 2015 TEST enviroment, and it was export from a CRM 2011 enviroment. Maybe the problem is the update. 

    Thank you so much for reply.

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