This topic contains 7 replies, has 0 voices, and was last updated by jerry.jalenak 8 years, 6 months ago.

  • Author
    Posts
  • #9823

    jerry.jalenak

    I need to trigger a workflow on an opportunity ONLY when it is created from a Lead record. I’ve prowled through the fields that are available in the workflow ‘condition’ field, but haven’t been able to find anything like a parent record that I could check against. Is this even possible in a workflow? If so, what are the ‘referring record’ fields that I need to look for?

    Thanks!
    This is a cached copy. Click here to see the original post.

  • #9824

    k_dunc

    Hi jerry.jalenak, I’m thinking you might be able to do this by setting the Initiation of your Workflow to Scheduled, then link it to a Saved Search Condition. In your Saved Search, base it on Opportunity record types, then in the Criteria, look for all Opportunities with a Date Created = ‘today’ (if you want it run daily for instance). Then add another criterion of something like (you’ll need to use the ‘Customer Fields…’) Stage = Lead. That might do the trick.

    If you need your Workflow to trigger more frequently than say once a day, you might then need to be a little more clever by adding a custom checkbox field, and have your Workflow ‘tick’ it after it’s done its processing. Then in your Saved Search, instead of looking for Opportunities created today, you could look for Opportunities where this checkbox is not ticked (so long as the other criterion exists too).

    Anyway, hope that helps.

    Cheers,

    Kirk.

  • #9825

    jerry.jalenak

    Kirk – Thanks for the ideas. It really needs to be almost transactional – i.e., from the Lead record, when you click on the ‘Create New’ icon and select Opportunity. The normal process is to open a new opportunity form with the lead information copied over – it is at this time that I need to set a couple of fields (on the opportunity) mandatory. Normally I would just make these mandatory at the form level, but the business requirements are such that I can’t do this. From what I can tell, there doesn’t seem to be a way to figure out where I came from (i.e. a Lead record as opposed to anything else).

  • #9826

    k_dunc

    If this is the case jerry.jalenak, then you might need to do this via a Client Script linked to the Opportunity record, or possibly even a Workflow Action Script within your Workflow. I’d probably recommend the Workflow Action Script, whereby you simply get the Customer ID, then do something like:

    Code:
    if (nlapiLookupField(‘customer’, id, ‘stage’, true) === ‘Lead’)
    {
    return ‘T’; // Returns true if the Customer is a Lead
    }
    return ‘F’;
    So this will return ‘true’ if the Customer is a Lead. In your Workflow, create a Workflow Field of type Checkbox that records the return value from the Workflow Action Script. As your first Action in your first State in the Workflow, call your Workflow Action Script and assign the value to the Workflow Field. Next, create an Action Group (or singular Actions if you don’t have many) and a series of Set Field Mandatory actions where your Criteria is ‘true’ for your Workflow Field. That should do the trick.

    Cheers.

  • #9827

    jerry.jalenak

    Kirk – thanks. Unfortunately my requirements have changed since I asked this question. But I’ll definitely file this away for future use!

  • #9828

    jerry.jalenak

    Ok, returning to this thread, and now that I understand the *new* requirements a bit more, here’s what I’m trying to figure out.

    From a Lead record, it is possible to create a new Opportunity (either from the Create New bar, or Sales -> Opportunities -> New Opportunity). On the Lead form we have two custom fields that, when the lead is initially created, we may not know the correct values to put in them. However, when an AE tries to create a new opportunity from the Lead, we *MUST* capture the information from the lead before allowing the AE to create the opportunity. So, the flow would be

    Lead -> Opportunity (if the custom fields are filled in)

    Lead -> error -> fill in the fields -> save -> Opportunity if the custom fields are NOT filled in)

    Does this make sense? I’m not sure how to detect what is essentially a button click and fire the workflow off. It’s not really a beforeSubmit / afterSubmit thing since the Lead record can be in View mode, and the Create New -> Opportunity link can be clicked.

    Any ideas?

  • #9829

    k_dunc

    Hi jerry.jalenak, if I understand your requirement correctly, you only want the AE to be able to create a new Opportunity IF the Custom Fields have been completed? If so, then you’d probably need a Client Script on the Opportunity record using the Page Init Function. In your script, you’d simply check the Custom Fields in your Lead record and perhaps do a redirect to the Lead record if the fields are not filled in.

    May I also suggest using a Field Changed Function (just in case your AE creates an Opportunity not from within the Lead record), whereby it checks to see if the ‘customer’ field has been changed, and if so, it does a look-up into that Customer record to once again verify the Stage (perhaps?) and your Custom Fields and return an error message or a redirect (or both).

    Is that the sort of thing you’re after?

  • #9830

    jerry.jalenak

    Kirk – essentially, yes. This was pretty much what I had come to, so thanks for validating my approach.

You must be logged in to reply to this topic.