locked
Is It possible to trigger a work flow on the selection of lookup? RRS feed

  • Question

  • Hi,

    Is it poosible to trigger a work flow once i select a value in lookup field?

    Thursday, August 29, 2013 7:10 AM

Answers

All replies

  • Hi,

    A workflow could easily be triggered when the record is saved using the standard workflow triggers.

    If you need the workflow to start the moment the lookup field is modified, you could trigger the workflow from JavaScript. See http://www.mscrmconsultant.com/2013/03/execute-workflow-using-javascript-in.html for an explanation on how to do this.


    Michael Palmer
    xRMPalmer     @MJFPalmer     Rockstar365

    • Proposed as answer by saemmang Thursday, August 29, 2013 7:48 AM
    • Marked as answer by RathiRojini Friday, August 30, 2013 10:21 AM
    Thursday, August 29, 2013 7:19 AM
  • Hi Palmer,

    I want to trigger the workflow when my form is in create mode and when i select a value in lookup field and not when i modify a record.

    Work flow is not getting triggered when i call the workflow on lookupfield selection field

    is it not possible to trigger a workflow manually while creating a record?

    Thursday, August 29, 2013 1:32 PM
  • Hi,

    You will not be able to manually start a workflow before the record is created. You will be able to do so once the record is created.

    HTH!


    Mamta

    Thursday, August 29, 2013 2:00 PM
  • It's not possible. A workflow will update the values in the database but, as they haven't been saved yet, there's nothing there that it can update.

    Whatever you need to do needs to be either done with JavaScript on the form (triggered by the change event of the lookup) or run the workflow after the record has been saved. The only in between method is to have some JavaScript code (on the lookup's change event) that performs a save, this could then be used to trigger the workflow.

    • Proposed as answer by Jon_Evans Thursday, August 29, 2013 2:20 PM
    Thursday, August 29, 2013 2:20 PM
  • You can use Plugin or JavaScript for trigger of your Business logic.

    I hope this helps. If my response answered your question, please mark the response as an answer and also vote as helpful.
    Mubasher Sharif
    Check out my about.me profile!
    http://mubashersharif.blogspot.com
    Linked-In Profile
    Follow me on Twitter!

    Thursday, August 29, 2013 2:27 PM
  • Hi,

    My scenerio is i have 2 forms

    1) blockUnit

    2) PropertyMaster

    i have written a workflow in blockunit.Whenever a Unit number is selected that Particular unit status will be chage in Poperty master as blocked.

    when i select Unit 401A in BlockUnit form it should trigger a workflow to update PropertyMaster for this Unit status as Blocked.

    This is the JavaScript am calling on selection of lookup.

    function RunWorkflow(entityId)
     {

    //alert(entityId)
    //var entityId = "{9B8EC3E6-B361-4B01-9B1B-8EC266636D6A}";
    var entityId = "{4B4164C4-5DD2-E211-9D9B-00155D62410A}";
    alert(entityId)
    var workflowProcessId = "{21ff89cd-d08d-4cea-a06e-f8eba615cf8b}";

      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\">" +

        Xrm.Page.context.getAuthenticationHeader() +

        "<soap:Body>" +

        "<Execute xmlns=\"http://schemas.microsoft.com/crm/2007/WebServices\">" +

        "<Request xsi:type=\"ExecuteWorkflowRequest\">" +

        "<EntityId>" + entityId + "</EntityId>" +

        "<WorkflowId>" + workflowProcessId + "</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);

    }

    Entity id is the record id which need to get updated.So i am passing the GUID of that Unitno from Propertymaster entity to this function.

    It is not working.

    Just for testing purpose i have passed a GUID of one record in Block Unit form itself.that time it is updating the status in propertymaster.

    My doubt is should i pass GUID belongs to same entity on which work flow is created ?if i pass GUID of different entity it wont work???

    Im updating a different entity on this workflow . so, it should work even before i save this record.

    Friday, August 30, 2013 4:41 AM
  • Hi,

    You should pass the GUID of the Entity record on which the workflow is create. Eg: if you created a workflow on contact entity then you should pass the ContactID to the workflow.

    If you pass GUID of a different entity then the workflow will not work.

    Thanks,

    Shaleen

    Friday, August 30, 2013 6:59 AM