How can I tell in a Business Process if a Target has been converted to a Lead?

I can write a report that includes all Targets which have an associated Lead - but is there a way in a Business Process to say "if this Target has been converted, perform this action"? There is no field that indicates a status of "Converted" (in fact, that's what I'm trying to automatically do).

Parents
  • I don't have BPM in my version but to display at the top of the Targets Record view whether a Target was converted to a lead, I just added a boolean (checkbox) custom field that I called converted_c to Prospects (Targets) with the following formula:

    not(equal(strlen(related($lead,"id")),0))

    Then in record view I added a field of type badge to the top of the view (similar to what you have in Leads) just after the "follow" button.

    So I  get a label when the Target is converted that looks like the green "converted" box you get on Leads. 

    You can probably imitate the formula in you BPM, to check if the related lead_id field has something in it of length non-zero.

    If not, you can add the custom field as I have it and then check if converted_c is set or not, but you will need to recalculate your existing Targets for the formula field to be populated in your past records.

    FrancescaS

  • Beautiful, thank you. The calculation works perfectly. 

    I'm curious about adding the badge - where did you do that?

Reply Children
  • Glad it helped,


    I added the badge to the top next to the name, when converted it's green and says "converted" when not converted it is gray and says "Not converted". Unlike the one on Leads it is NOT clickable, it's just a visual.

    If you want it clickable I suggest you take a look at that field type in the core files and see if you can reverse engineer it.

    To add the field type "badge" to Prospects I added my custom badge field type:

    custom/modules/Prospects/clients/base/fields/badge/badge.js

    ({
        /**
         * @inheritdoc
         *
         * This field doesn't support `showNoData`.
         */
        showNoData: false,
    
        /**
         * @inheritdoc
         *
         * The badge is always a readonly field.
         */
        initialize: function(options) {
          options.def.readonly = true;
          this._super('initialize',[options]);
        },
    })
    

    and custom/modules/Prospects/clients/base/fields/badge/detail.hbs

        {{#eq value "0"}}
            <span class="label label-pending">{{str "LBL_UNCONVERTED" this.module}}</span>
        {{/eq}}
        {{#eq value "1"}}
            <span class="label label-success">{{str "LBL_CONVERTED" this.module}}</span>
        {{/eq}}
    

    in the header panel of the record view just after the "follow" I added my custom field

    custom/modules/Prospects/clients/base/views/record/record.php

            array (
              'name' => 'converted_c',
              'type' => 'badge',
              'readonly' => true,
              'related_fields' =>
              array (
                0 => 'converted_c',
                1 => 'lead_id',
              ),
            ),
    

    FrancescaS