Show Action when condition is meet

Hi all,

I am creating a workflow. in my workflow, I want to have a condition before proceed to the next action. Based on this condition, I will show/hide the next action.

for example: 

if Lead company is match (Lead_CompanyMatch='Y'), show action "Company promoted" and then set the assigned to value

if Lead company is not match, hide action "Assign to Salesperson"

I thought I need to use conditional rule. but it still show the "Company promoted" whether or not the Lead_CompanyMatch is equal to 'Y' or not.

     

Please help. Thank you.

  • 0

    Hi Murni

    Lead_CompanyMatch ='Y' is an assignment.  Lead_CompanyMatch=='Y' is a test.

    See:  (+) Accessing Context Information in the Javascript Condition of a Workflow Rule (including for Custom Entities) - Sage CRM Hints, Tips and Tricks - Sage CRM - Community Hub

    In Primary, Global and Transition rules the javascript condition is used to determine whether the rule is available in the interface.  Conditional rules always display.  The Javascript condition is used to determine which workflow actions are carried out when the condition is false and when it is true.

     See:  https://youtu.be/ekRD-XFr404  Have a watch from 5:28 onwards.

  • 0 in reply to Sage CRM

    Hi Sage CRM, thank you. that works.

    Valid = (Lead_CompanyMatch=="Y");

    I further test to validate with Company field as well, based on the example from the link you provide. but this code have an error.

    Error: Workflow Java Script jscript error: Object doesn't support this property or method Line: 1 Char: 7555
    
    if (Lead_CompanyMatch=="Y" && CRM.GetContexInfo("Company","Comp_Type")=="Customer")
    { Valid = true; }
    else
    {Valid = false;}

    If I validate by Comp_Type, it will produce this error:

    Error: Workflow Java Script jscript error: 'Comp_Type' is undefined Line: 1 Char: 7555
    
    Valid = (Comp_Type=="Y");

    Is there any way to validate with Comp_Type as well?

  • 0 in reply to murni

    Whilst I don't like using the Condition rules, I just use normal transitional rules. You might want to try an adjustment to your script try in there 

    Valid=(lead_companymatch=='Y'); 

    Note the single speechmarks. Secondly I'm not sure your further test would work, as you are looking at a Lead, so contextually you're not at a company and so there is no Company context to get. Instead you might need to look for the company record

    var CompRec = eWare.FindRecord("Company", "comp_companyid="+lead_primarycompanyid);
    if (CompRec.comp_type=='Customer')
    {
    Valid = true;
    }
    else
    {
    Valid = false;
    }