locked
how to fire a particular plugin block for custom isv buttons RRS feed

  • Question

  • hi

    There is custom entity Budget for which i have a custom isv button "Copy", to create new budget based on existing  . When this button is clicked a particular block (function) in plugin should fire.

    How can i do this? is it possible to identify which button is fired.

    Is it possible to pass parameters to plugin using java script?

    is there any other way?

    Please advise me on this.

     

    Friday, August 13, 2010 9:19 AM

Answers

All replies

  • It seems it's not possible, you can use JS to implment the same functionality


    Mahain : http://mahenderpal.wordpress.com
    Friday, August 13, 2010 9:29 AM
    Moderator
  • Thanks Mahender

    but there is a lot of business logic involved, also existing record details are also changing

    new record creation and old record updation needs to be one transaction.

    Please advise me on this.

    Friday, August 13, 2010 9:34 AM
  • Please tell us your requirement that you have to implement so that we can help you to provide some solution on the same


    Mahain : http://mahenderpal.wordpress.com
    Friday, August 13, 2010 9:40 AM
    Moderator
  • There is a custom entity : Budget (for fiscal year)

    There are fields like startdate, enddate, departmentid,officeid,consumerid ,amount,approved amt etc.

    suppose a budget is created for particular consumer for some combination.

    Later on some changes are required in budget say increase in amount. Now the requirement is once the budget is approved for selected consumer for selected fiscal year,user can not directly modify details for that record. For that i need a button to copy and create a new record based on the existing one. user can modify his new record and send it for approval. Once the new record (details) is approved , previous record will become inactive.

    Also there are other isv button on form for approval on different levels.

    Please let me know if more information is required.

     

    Friday, August 13, 2010 9:50 AM
  • Hi,

    I think you can implement this through workflow, you can clone your budget entity record through workflow refer this Post for your reference, Also you can call workflow through JS code

     

    Hope it will help you !!!


    Mahain : http://mahenderpal.wordpress.com
    Friday, August 13, 2010 10:04 AM
    Moderator
  • Thanks Mahender

    let me see this

    Friday, August 13, 2010 10:10 AM
  • Hi Mahender

    I just tried workfow but the problem over here is values are hardcoded (let say in workflow i have to select consumer and this same consumer is copied rather the consumer which actually exists in record) ,

    I want to copy the record details.

    Please correct me if i am doing something wrong.

     

    Friday, August 13, 2010 10:34 AM
  • Could you please explain with some more detail


    Mahain : http://mahenderpal.wordpress.com
    Friday, August 13, 2010 10:40 AM
    Moderator
  • Sorry mahender i was making a little mistake.

    let me try again.

    Friday, August 13, 2010 10:42 AM
  • 1. Create a datetime attribute, put it on the form, then hide it with JS.

    2. Onclick of the button, change that datetime attributes datavalue to now (crmForm.all.<field>.DataValue = new Date()), then call crmForm.Save();

    3. When your plugin is called, you can know that your button was clicked, since your target entity property collection contains this field.

    Ofcurse, calling and external web service using ajax when the buttons is clicked, is just as good.

    Friday, August 13, 2010 12:23 PM
  • Hi mahender

    workflow is getting fired when it is on ondemand

    but when i trying to run it through javascript its not getting executed.

    please let me know if something is wrong with following code.

     

    I have fetched the workflowid from the system using ctrl+N

     var caseid = crmForm.ObjectId;
     var authenticationHeader = GenerateAuthenticationHeader();

     var xml = "" + "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +    
     "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +    
     authenticationHeader  +    "  <soap:Body>" +    
     "    <Execute xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" +    
    "      <Request xsi:type=\"ExecuteWorkflowRequest\">" +    
     "        <EntityId>" + caseid + "</EntityId>" +    
     "        <WorkflowId>75505BAF-C0F5-4DE6-8A74-72F0F51BEBB9</WorkflowId>" +    
     "      </Request>" +     "    </Execute>" +     "  </soap:Body>" +     "</soap:Envelope>" +     "";

        var xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");

        xmlhttp.open("POST", this.ServerURL +"/mscrmservices/2007/crmservice.asmx", false);

        xmlhttp.setRequestHeader("Content-Type", "text/xml; charset=utf-8");

        xmlhttp.setRequestHeader("SOAPAction", "http://schemas.microsoft.com/crm/2007/WebServices/Execute");

     

    Friday, August 13, 2010 12:29 PM
  • Try this code

    var entityId=crmForm.ObjectId;
    var workflowId='75505BAF-C0F5-4DE6-8A74-72F0F51BEBB9';
    var xml = "" +
    "<?xml version=\"1.0\" encoding=\"utf-8\"?>" +
    "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\">" +
     GenerateAuthenticationHeader() +
      "  <soap:Body>" +
       "    <Execute xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" +
        "      <Request xsi:type=\"ExecuteWorkflowRequest\">" +
        "        <EntityId>" + entityId + "</EntityId>" +
        "        <WorkflowId>" + workflowId + "</WorkflowId>" +
        "      </Request>" +
        "    </Execute>" +
        "  </soap:Body>" +
        "</soap:Envelope>" +
        "";
     
    var xmlHttpRequest = new ActiveXObject("Msxml2.XMLHTTP");
    xmlHttpRequest.Open("POST", "/mscrmservices/2007/CrmService.asmx", false);
    xmlHttpRequest.setRequestHeader("SOAPAction","http://schemas.microsoft.com/crm/2007/WebServices/Execute");
    xmlHttpRequest.setRequestHeader("Content-Type", "text/xml; charset=utf-8");
    xmlHttpRequest.setRequestHeader("Content-Length", xml.length);
    xmlHttpRequest.send(xml);
    var resultXml = xmlHttpRequest.responseXML;


    Mahain : http://mahenderpal.wordpress.com
    Friday, August 13, 2010 2:24 PM
    Moderator
  • Thanks again Mahender

    It worked.

    Friday, August 13, 2010 2:43 PM