Business rules to compare fields and set value

farci
Mega Expert

Hi Team,

I am writing a business rules by selecting filters and action what it has to do, when things match to the condition set. But to no avail

for some reason its not working.

Could you please suggest a script that I can write to get this in place.

Below are the screenshots for your reference.

find_real_file.png

find_real_file.png

to elaborate my requirement further.

If my perfection logic is 1

If my SI Validation Result is greater or equal to expected target. I need to set the Legend field as 'Greater than or Equal to Expected Target'

if my SI Validation Result is in between expected and minimum target (greater or equal to minimum target but lesser than expected target). I need to set the Legend field as 'Between Expected & Minimum Target'

if my SI Validation Result   is less than minimum target. I need to set the Legend field as 'Less than Minimum Target'

and if my SI Validation Result is blank or no value. I need to set the Legend field as 'No Reportable Data'

if my perfection logic is 2

If my SI Validation Result is lesser or equal to expected target. I need to set the Legend field as 'Greater than or Equal to Expected Target'

if my SI Validation Result is in between expected and minimum target (lesser or equal to minimum target but greater than expected target). I need to set the Legend field as 'Between Expected & Minimum Target'

if my SI Validation Result   is greater than minimum target. I need to set the Legend field as 'Less than Minimum Target'

and if my SI Validation Result is blank or no value. I need to set the Legend field as 'No Reportable Data'.

Thank You for your support in advance.

Regards,

Narmi

1 ACCEPTED SOLUTION

It could be that it is returning a string. Try



if(current.s_wf == ' 1')


View solution in original post

7 REPLIES 7

Chuck Tomasi
Tera Patron

Hi Narmi,



Thank you for the clarification of requirements/logic and screenshot. Based on what you described, you are going to need to check the advanced button and do some scripting. You have multiple conditions and the scriptless option of the business rule requires several (and nested also.)



Without specific field names and values, it's difficult for me to draft a script for you, but use the field names in the script and the values of your choice list (not necessarily the same as the labels.)



For example:


  if (current.u_perfection_logic == 1) {


        if (current.u_si_validation_result >= current.u_expected_target) {


                  current.legend = 'Greater than or Equal to Expected Target';


      }


    // More comparisons and value setting here.


  }


Hi Chuck,



Thank You for the quick reply.



Your code works perfectly fine. But a small concern is, it should give me 'No Value' or --None-- when my Workflow state (s_wf) is 1 otherwise it has to work as per the logic. Which it is not happening. I get 'No Reportable Data' even if I have the workflow state (s_wf) as 1. any I am missing here.



Below is my code.  



(function executeRule(current, previous /*null when async*/) {




  // Add your code here


  if (current.per_log == 1)


  {


  if(current.si_vr >= current.exp_sl)


  {


  current.legends = 'Greater than or Equal to Expected Target';



  }


  if(current.si_vr < current.exp_sl && current.si_vr >= current.min_sl)


  {


  current.legends = 'Between Expected & Minimum Target';


  }



  if(current.si_vr < current.min_sl)


  {


  current.legends = 'Less than Minimum Target';


  }


  if(current.s_wf == 1)


  {


  current.legends = '--None--';


  }


  if (current.si_vr == '')


  {


  current.legends = 'No Reportable Data';


  }


  }



  if(current.per_log == 2)


  {


  if(current.si_vr <= current.exp_sl)



  {


  current.legends = 'Greater than or Equal to Expected Target';



  }


  if(current.si_vr > current.exp_sl && current.si_vr <= current.min_sl)


  {


  current.legends = 'Between Expected & Minimum Target';


  }



  if(current.si_vr > current.min_sl)


  {


  current.legends = 'Less than Minimum Target';


  }


  if(current.s_wf == 1)


  {


  current.legends = '--None--';


  }



  if (current.si_vr == '')


  {


  current.legends = 'No Reportable Data';


  }


  }




})(current, previous);



Regards,


Narmi


It could be that it is returning a string. Try



if(current.s_wf == ' 1')


Hi Narmi,



Did that resolve your issue?