locked
CRM 2011 How to disable resolution case form RRS feed

  • Question

  • my organization want to eliminate resolution case form !

    I hid resolved case button and created a new resolved case button using ribbon workbench.

    I replaced the action of the botten with a javascript function that closes the case using the CRM webservices

    When I press on my replaced botten nothing happend, What can cause the problem?

    The function:

    function onResolveCaseBtn()

    {

    UpdateStatus(1,5,incident,Xrm.Page.data.entity.getId()) where 1 is the state and 5 is the status for Resolve case.

    }

    function UpdateStatus(state, status, entityname, ID) {
        var request = "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">";
        request += "<s:Body>";
        request += "<Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">";
        request += "<request i:type=\"b:SetStateRequest\" xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\" xmlns:b=\"http://schemas.microsoft.com/crm/2011/Contracts\">";
        request += "<a:Parameters xmlns:c=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">";
        request += "<a:KeyValuePairOfstringanyType>";
        request += "<c:key>EntityMoniker</c:key>";
        request += "<c:value i:type=\"a:EntityReference\">";
        request += "<a:Id>" + ID + "</a:Id>";
        request += "<a:LogicalName>" + entityname + "</a:LogicalName>";
        request += "<a:Name i:nil=\"true\" />";
        request += "</c:value>";
        request += "</a:KeyValuePairOfstringanyType>";
        request += "<a:KeyValuePairOfstringanyType>";
        request += "<c:key>State</c:key>";
        request += "<c:value i:type=\"a:OptionSetValue\">";
        request += "<a:Value>" + state + "</a:Value>";
        request += "</c:value>";
        request += "</a:KeyValuePairOfstringanyType>";
        request += "<a:KeyValuePairOfstringanyType>";
        request += "<c:key>Status</c:key>";
        request += "<c:value i:type=\"a:OptionSetValue\">";
        request += "<a:Value>" + status + "</a:Value>";
        request += "</c:value>";
        request += "</a:KeyValuePairOfstringanyType>";
        request += "</a:Parameters>";
        request += "<a:RequestId i:nil=\"true\" />";
        request += "<a:RequestName>SetState</a:RequestName>";
        request += "</request>";
        request += "</Execute>";
        request += "</s:Body>";
        request += "</s:Envelope>";

        //send set state request
        $.ajax({
            type: "POST",
            contentType: "text/xml; charset=utf-8",
            datatype: "xml",
            url: Xrm.Page.context.getServerUrl() + "/XRMServices/2011/Organization.svc/web",
            data: request,
            beforeSend: function (XMLHttpRequest) {
                XMLHttpRequest.setRequestHeader("Accept", "application/xml, text/xml, */*");
                XMLHttpRequest.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute");
            },
            success: function (data, textStatus, XmlHttpRequest) {
                window.location.reload(true);
            },
            error: function (XMLHttpRequest, textStatus, errorThrown) {
                alert(errorThrown);
            }
        });

    }

    The Error that i get while trying to use the botten:(send dont send error)

    CrmScriptErrorReport>
      <ReportVersion>1.0</ReportVersion>
      <ScriptErrorDetails>
       <Message>'incident' is undefined</Message>
       <Line>129090973</Line>
       <URL>/_root/homepage.aspx?etc=112&pagemode=iframe&sitemappath=Workplace%7cMyWork%7cnav_cases</URL>
       <PageURL>/_root/homepage.aspx?etc=112&pagemode=iframe&sitemappath=Workplace%7cMyWork%7cnav_cases</PageURL>
       <Function>onResolveCaseBtn()</Function>
       <CallStack>
        <Function>onResolveCaseBtn()</Function>
        <Function>anonymous($p0,$p1,$p2,$p3){Mscrm.CrmHeader.setScriptFile(Mscrm.CrmUri.create($p1),true);for(var$v_0=window,$v_1=$p0.split("."),$v_2=0;$v_2<$v_1.length;$v_2++)if($v_0)$v_0=$v_0[$v_1[$v_2]];if(!IsNull($v_0)&&typeof$v_0===Mscrm.TypeNames.functionType){var$v_3=this.$E0_1($p2,$p3);return$v_0.apply(null,$v_3)}returnnull}</Function>
        <Function>anonymous($p0,$p1,$p2,$p3){var$v_0=this.getCommandDefinition($p0,$p1);if(IsNull($v_0)||IsNull($v_0.Actions))returnfalse;for(var$v_1=0;$v_1<$v_0.Actions.length;$v_1++){var$v_2=$v_0.Actions[$v_1];switch($v_2.ActionType){case2:this.$Es_1($v_2.Attributes);break;case3:var$v_3=$v_2.Attributes;this.$Bd_1($v_3.FunctionName,$v_3.Library,$v_2.Parameters,$p2);break;case1:this.$Et_1($v_2.Attributes,$v_2.Parameters);break}}returntrue}</Function>
        <Function>anonymous($p0,$p1,$p2){var$v_0=this.parseCommandFromRibbon($p0),$v_1=this.$8J_1($v_0.command,$v_0.entityLogicalName,$p1,$p2),$v_2=$p1;if(!IsNull($v_2)&&!isNullOrEmptyString($v_2.PopulationXML)&&!$v_2.SuppressCommandIncludes){var$v_3=null;if($v_0.entityContext==="Form"){var$v_4=$find("crmFormSelector");if($v_4)$v_3=$v_4.get_currentFormId()}$v_2.PopulationXML=this.$GL_1($v_2.PopulationXML,$v_0.entityLogicalName,$v_3)}return$v_1}</Function>
       </CallStack>
      </ScriptErrorDetails>
      <ClientInformation>
       <BrowserUserAgent>Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729; HelpByLeo; .NET4.0C; .NET4.0E; MS-RTC EA 2)</BrowserUserAgent>
       <BrowserLanguage>en-us</BrowserLanguage>
       <SystemLanguage>he</SystemLanguage>
       <UserLanguage>he</UserLanguage>
       <ScreenResolution>1069x855</ScreenResolution>
       <ClientName>Web</ClientName>
       <ClientTime>2013-08-04T17:42:43</ClientTime>
      </ClientInformation>
      <ServerInformation>
        <OrgLanguage>1037</OrgLanguage>
        <OrgCulture>1037</OrgCulture>
        <UserLanguage>1037</UserLanguage>
        <UserCulture>1037</UserCulture>
        <OrgID>{C4138F10-C09B-4A13-AF36-FD1A4B3997DB}</OrgID>
        <UserID>{D66C35D4-AC58-E211-BBD4-005056835320}</UserID>
        <CRMVersion>5.0.9690.2839</CRMVersion>
      </ServerInformation>
    </CrmScriptErrorReport>

    Thanks everybody

    Sunday, August 4, 2013 6:29 PM

All replies

  • Where you are calling the UpdateStatus function you need to put 'incident' in quote marks otherwise it thinks it's a variable.

    Hope that helps

    Paul


    If my response helped you find your answer please show your thanks by taking the time to "Mark As Answer" and "Vote As Helpful".

    Twitter LinkedIn Facebook Blog Magnetism

    Sunday, August 11, 2013 8:01 AM