locked
Change statecode and statuscode on click of custom button click RRS feed

All replies

  • Hello,

    1. You are often ask question and it would be a really great in case you will have a chance to close opened threads marking answers. Here is the list of threads that you've started and haven't closed yet:

    https://social.microsoft.com/Forums/en-US/2a6014dc-bcbd-4673-ab85-dc4c8c70268c/facing-problem-in-adding-value-in-status-reason?forum=crmdevelopment#b0defdea-e335-476a-a229-674f005060ab

    https://social.microsoft.com/Forums/en-US/4d2dd714-3d1f-41ea-8924-09b0df790426/which-is-the-best-way-to-develop-plug-in?forum=crm#8b7b7036-549c-4e59-af6e-5719f6878173
    https://social.microsoft.com/Forums/en-US/e3f4fc5d-256f-4966-ac00-e85300ee5baf/how-can-i-add-option-in-menu?forum=crmdevelopment#e3f4fc5d-256f-4966-ac00-e85300ee5baf

    https://social.microsoft.com/Forums/en-US/14d9f97a-872d-4651-869d-4f2336133443/how-to-add-multiple-products-in-order-through-jquery?forum=crmdevelopment#f079f350-0980-4a2f-be65-ddc7eae9070c
    https://social.microsoft.com/Forums/en-US/3a1f2b99-2589-483d-9ad6-c7c27fd6c22c/create-custom-entity-and-its-attributes-and-open-form-in-dynamic-crm-2015?forum=crm#f6d1d283-ef0d-45d3-a48f-aa2d587e8ee9

    https://social.microsoft.com/Forums/en-US/77ae50f8-855e-47e7-ba2d-488909a9bcf3/how-to-fetch-orderid-of-a-selected-order-and-fetch-products-of-that-order-?forum=crm#77ae50f8-855e-47e7-ba2d-488909a9bcf3

    https://social.microsoft.com/Forums/en-US/fc343011-2695-49f5-8210-e516875992e2/xrmservicetoolkit-is-not-defined?forum=crm#c0620b6b-f6d2-493f-ad5d-9810e5da5f7a

    https://social.microsoft.com/Forums/en-US/2ae5791e-3e39-4b57-b673-e0f9db0c961e/can-we-place-our-control-in-place-of-control-exists-in-ms-crm-form?forum=crm#2ae5791e-3e39-4b57-b673-e0f9db0c961e

    2. To understand your issue it would be great if you will write what you've tried and what issue you've faced.


    Dynamics CRM MVP
    My blog

    Monday, September 14, 2015 11:29 AM
    Moderator
  • How can i close thread ?
    Monday, September 14, 2015 11:42 AM
  • How can i close thread ?

    You have "Mark as answer" button under every answer posted.

    Dynamics CRM MVP
    My blog

    Monday, September 14, 2015 11:55 AM
    Moderator
  • call action on click of your button. and in that action change status.

    Hope this helps. ----------------------------------------------------------------------- Santosh Bhagat If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"

    Tuesday, September 15, 2015 9:44 AM
  • Thank you santosh for you reply,

    I am using set..

     var requestMain = ""
            requestMain += "<s:Envelope xmlns:s=\"http://schemas.xmlsoap.org/soap/envelope/\">";
            requestMain += "  <s:Body>";
            requestMain += "    <Execute xmlns=\"http://schemas.microsoft.com/xrm/2011/Contracts/Services\" xmlns:i=\"http://www.w3.org/2001/XMLSchema-instance\">";
            requestMain += "      <request i:type=\"b:SetStateRequest\" xmlns:a=\"http://schemas.microsoft.com/xrm/2011/Contracts\" xmlns:b=\"http://schemas.microsoft.com/crm/2011/Contracts\">";
            requestMain += "        <a:Parameters xmlns:c=\"http://schemas.datacontract.org/2004/07/System.Collections.Generic\">";
            requestMain += "          <a:KeyValuePairOfstringanyType>";
            requestMain += "            <c:key>EntityMoniker</c:key>";
            requestMain += "            <c:value i:type=\"a:EntityReference\">";
            requestMain += "              <a:Id>dcb1d9cd-1dae-e011-8cbc-1cc1de7955db</a:Id>";
            requestMain += "              <a:LogicalName>new_purchaseorder</a:LogicalName>";
            requestMain += "              <a:Name i:nil=\"true\" />";
            requestMain += "            </c:value>";
            requestMain += "          </a:KeyValuePairOfstringanyType>";
            requestMain += "          <a:KeyValuePairOfstringanyType>";
            requestMain += "            <c:key>State</c:key>";
            //requestMain += "            <c:key>Active</c:key>";
            requestMain += "            <c:value i:type=\"a:OptionSetValue\">";
            //requestMain += "              <a:Value>1</a:Value>";
            requestMain += "              <a:Value>0</a:Value>";
            requestMain += "            </c:value>";
            requestMain += "          </a:KeyValuePairOfstringanyType>";
            requestMain += "          <a:KeyValuePairOfstringanyType>";
            requestMain += "            <c:key>Status</c:key>";
            //requestMain += "            <c:key>Release</c:key>";
            requestMain += "            <c:value i:type=\"a:OptionSetValue\">";
            requestMain += "              <a:Value>2</a:Value>";
            //requestMain += "              <a:Value>1</a:Value>";
            requestMain += "            </c:value>";
            requestMain += "          </a:KeyValuePairOfstringanyType>";
            requestMain += "        </a:Parameters>";
            requestMain += "        <a:RequestId i:nil=\"true\" />";
            requestMain += "        <a:RequestName>SetStateRequest</a:RequestName>";
            requestMain += "      </request>";
            requestMain += "    </Execute>";
            requestMain += "  </s:Body>";
            requestMain += "</s:Envelope>";
            var req = new XMLHttpRequest();
            req.open("POST", SDK.SAMPLES._getClientUrl(), true)
            // Responses will return XML. It isn't possible to return JSON.
            req.setRequestHeader("Accept", "application/xml, text/xml, */*");
            req.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
            req.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute");
            var successCallback = null;
            var errorCallback = null;
            req.onreadystatechange = function () { SDK.SAMPLES.SetStateResponse(req, successCallback, errorCallback); };
            req.send(requestMain);

    But here I am getting error-Method not allow..I don;t understand why this error comes?

    Can you please check my reuest once..Am i missing somethig?


    • Edited by NikkiShah Tuesday, September 15, 2015 10:22 AM
    Tuesday, September 15, 2015 9:50 AM
  • 1. create a action for your entity.

    2. call that action below is he sample for to call.

    3. in that action change the status. This will create the history of your action call and show the actual error. you can call this async.

    var

    ymfSDKAsset = {

        _getServerUrl:

    function() {

           

    vare = "/XRMServices/2011/Organization.svc/web";

           

    vart = "";

           

    if(typeofGetGlobalContext == "function") {

               

    varn = GetGlobalContext();

                t = n.getServerUrl()

            }

    else{

               

    if(typeofXrm.Page.context == "object") {

                    t = Xrm.Page.context.getServerUrl()

                }

               

    else{

                   

    thrownewError("Unable to access the server URL")

                }

            }

           

    if(t.match(/\/$/)) {

                t = t.substring(0, t.length - 1)

            }

           

    returnt + e

        },

        callNavRequestFixedAsset:

    function(AssetType) {

           

    //  var OwnerCode = AccessOwnerCode();


           

    varassetId = Xrm.Page.data.entity.getId(); assetId = assetId.substring(1, assetId.length - 1);

           

    vari = "";

            i +=

    '<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">';

            i +=

    '<s:Body>';

            i +=

    '<Execute xmlns="http://schemas.microsoft.com/xrm/2011/Contracts/Services" xmlns:i="http://www.w3.org/2001/XMLSchema-instance">';

            i +=

    '<request xmlns:a="http://schemas.microsoft.com/xrm/2011/Contracts">';

            i +=

    '<a:Parameters xmlns:b="http://schemas.datacontract.org/2004/07/System.Collections.Generic">';

            i +=

    '<a:KeyValuePairOfstringanyType>';

            i +=

    '<b:key>AssetType</b:key>';

            i +=

    '<b:value i:type="c:string" xmlns:c="http://www.w3.org/2001/XMLSchema">'+ AssetType + '</b:value>';

            i +=

    '</a:KeyValuePairOfstringanyType>';

             i +=

    '<a:KeyValuePairOfstringanyType>';

            i +=

    '<b:key>Target</b:key>';

            i +=

    '<b:value i:type="a:EntityReference">';

            i +=

    '<a:Id>'+ assetId + '</a:Id>';

            i +=

    '<a:LogicalName>ymf_equipment</a:LogicalName>';

            i +=

    '<a:Name i:nil="true" />';

            i +=

    '</b:value>';

            i +=

    '</a:KeyValuePairOfstringanyType>';

            i +=

    '</a:Parameters>';

            i +=

    '<a:RequestId i:nil="true" />';

            i +=

    '<a:RequestName>ymf_callNavRequestForAsset</a:RequestName>';

            i +=

    '</request>';

            i +=

    '</Execute>';

            i +=

    '</s:Body>';

            i +=

    '</s:Envelope>';

           

    vars = newXMLHttpRequest;

           

    varerrorHandler;

            s.open(

    "POST", ymfSDKAsset._getServerUrl(), false);

            s.setRequestHeader(

    "Accept", "application/xml, text/xml, */*");

            s.setRequestHeader(

    "Content-Type", "text/xml; charset=utf-8");

            s.setRequestHeader(

    "SOAPAction", "http://schemas.microsoft.com/xrm/2011/Contracts/Services/IOrganizationService/Execute");

            s.onreadystatechange =

    function() {

                ymfSDKAsset.SetStateResponse(s,

    null, errorHandler)

            };

            s.send(i)

        },

        SetStateResponse:

    function(e, t, n) {

           

    if(e.readyState == 4) {

               

    if(e.status == 200) {

                    alert(

    "Asset added in asset register.");

                }

               

    if(t != null) {

                    t()

                }

            }

           

    else{

                ymfSDKAsset._getError(e.responseXML);

            }

        }

        ,

        _getError:

    function(e) {

            btnNameCS =

    null; desc_val = null; entryNo = null;

           

    vart = "Unknown Error (Unable to parse the fault)"; if(typeofe == "object") {

               

    try{

                   

    varn = e.firstChild.firstChild; for(varr = 0; r < n.childNodes.length; r++) {

                       

    vari = n.childNodes[r]; if("s:Fault"== i.nodeName) {

                           

    for(vars = 0; s < i.childNodes.length; s++) {

                               

    varo = i.childNodes[s];

                               

    if("faultstring"== o.nodeName) {

                                }

                               

    if("faultstring"== o.nodeName

                        ) {

                                    t = o.text +

    " textContent:="+ n.textContent;

                                    alert(o.firstChild.data);

                                   

    break


                                }

                            }

    break


                        }

                    }

                }

    catch(u) { }

            }

    returnnewError(t)

        }

    }


    Hope this helps. ----------------------------------------------------------------------- Santosh Bhagat If this post answers your question, please click "Mark As Answer" on the post and "Vote as Helpful"

    Tuesday, September 15, 2015 10:45 AM
  • Getting "Internal Server Error"..
    Tuesday, September 15, 2015 11:46 AM